【发布时间】:2016-06-23 21:55:16
【问题描述】:
我想通过 lodash 制作这个:
first = { one: 1, two: 2, three: 3 }
second = { three: 3, one: 1 }
_.CustomisEqual(first, second);
// → true
third = { one: 1, two: 2, three: 3 }
fourth = { three: 4, one: 1 }
_.CustomisEqual(third, fourth);
// → false
但是通常_.isEqual不支持这种比较方法,有没有办法通过lodash进行这种比较?
【问题讨论】:
-
您是在问如何编写这样的函数吗?你试过什么?你检查过
isMatch函数吗? -
是的,
isMatch为我工作,谢谢 -
_.isMatch()在“第二个”变量是第一个参数并且“第一个”变量是第二个参数时不起作用。
标签: javascript underscore.js lodash