topic description
JavaScript authoritative Guide [3.7 immutable primitive values and mutable object references] section, referring to
The comparison ofobjects is not a comparison of values: even if two objects contain the same properties and the same values, they are not equal.
I think it"s okay to understand this, because it"s not in the same memory, it"s all independent of each other. Example given:
var o={x:1},p={x:1}; //
o===p //=>false:
var a=[],b=[]; //
a===b //=>false;
arrays are also objects and are declared separately.
but when it comes to the latter function, I"m confused:
function equalArrays(a,b){
if(a.length!=b.length)return false; //
for(var i=0;i<a.length;iPP){ //
if(a[i]!==b[i]) return false; //
return true; //
}
}
object equality should be a reference to the object identifier pointing to the same memory address, right?
even if you use the "=" mode to make two objects equal.
the above example only determines that the "key-value" pairs of the object are consistent, and can"t prove that an and b point to the same memory address?