Skip to content

defaultsDeep

js
_.defaultsDeep(object, [sources])

此方法与 _.defaults 类似,不同之处在于它以递归方式分配默认属性。

¥This method is like _.defaults except that it recursively assigns default properties.

注意:此方法改变 object

¥Note: This method mutates object.

新增于

¥Since

3.10.0

参数

¥Arguments

  1. object (对象):目标对象。

    ¥object (Object): The destination object.

  2. [sources] (...对象):起始位置。

    ¥[sources] (...Object): The source objects.

返回

¥Returns

(对象):返回 object

¥(Object): Returns object.

示例

¥Example

js
_.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
// => { 'a': { 'b': 2, 'c': 3 } }

Lodash v4.17 中文网 - 粤ICP备13048890号