Closed Yhaojing closed 7 years ago
@Yhaojing objects (and arrays) in JavaScript are compared by reference so comparing like this will give you false
:
var a = [1, 2];
var b = [1, 2];
console.log(a === b);
//=> false
This is because they are actually 2 different arrays. If the arrays are the same instance, then you will get true
:
var a = [1, 2];
var b = a;
console.log(a === b);
//=> true
I hope this helps. I'm going to close this issue, but if you have more questions, you can ask here or try Stack Overflow.
expected =>
['a', 'd', [3]]
actual =>['a', [1, 2]]
The first, only find different a and b, not different b and a, The second, if It has object, can not compare 。Can you understand me?
edited by @doowb: code formating