主题
isEqual
js
_.isEqual(value, other)
在两个值之间执行深度比较以确定它们是否相等。
¥Performs a deep comparison between two values to determine if they are equivalent.
注意:此方法支持比较数组、数组缓冲区、布尔值、日期对象、错误对象、映射、数字、Object
对象、正则表达式、集合、字符串、符号和类型化数组。Object
对象通过其自身而非继承的可枚举属性进行比较。函数和 DOM 节点通过严格相等进行比较,即 ===
。
¥Note: This method supports comparing arrays, array buffers, booleans, date objects, error objects, maps, numbers, Object
objects, regexes, sets, strings, symbols, and typed arrays. Object
objects are compared by their own, not inherited, enumerable properties. Functions and DOM nodes are compared by strict equality, i.e. ===
.
新增于
¥Since
0.1.0
参数
¥Arguments
value
(*):要比较的值。¥
value
()*: The value to compare.other
(*):要比较的另一个值。¥
other
()*: The other value to compare.
返回
¥Returns
(布尔):如果值相等,则返回 true
,否则返回 false
。
¥(boolean): Returns true
if the values are equivalent, else false
.
示例
¥Example
js
var object = { 'a': 1 };
var other = { 'a': 1 };
_.isEqual(object, other);
// => true
object === other;
// => false