主题
conformsTo
js
_.conformsTo(object, source)通过使用 object 的相应属性值调用 source 的谓词属性来检查 object 是否符合 source。
¥Checks if object conforms to source by invoking the predicate properties of source with the corresponding property values of object.
注意:当部分应用 source 时,此方法相当于 _.conforms。
¥Note: This method is equivalent to _.conforms when source is partially applied.
新增于
¥Since
4.14.0
参数
¥Arguments
object(对象):要反转的对象。¥
object(Object): The object to inspect.source(对象):要遵循的属性谓词的对象。¥
source(Object): The object of property predicates to conform to.
返回
¥Returns
(布尔):如果 object 符合则返回 true,否则返回 false。
¥(boolean): Returns true if object conforms, else false.
示例
¥Example
js
var object = { 'a': 1, 'b': 2 };
_.conformsTo(object, { 'b': function(n) { return n > 1; } });
// => true
_.conformsTo(object, { 'b': function(n) { return n > 2; } });
// => false