0
Logic Question from Javascript
Not looking for answer, just explanation. var a={}, b={} console.log(a===b) //Returns false???? Both are same type, same scope, both empty values why are they not the same?
3 Antworten
+ 4
+ 2
Aren't those 2 different objects?
Not sure about JavaScript but in Java it would return false because both will have different reference.
+ 1
nice article honfu,
just to provide further enrichment : the isEquivalent function in the article uses !== to check the values in the objects, this assumed that they will be string, number or boolean; when the object is nested, the values are also object-type, including array, this approach fails. instead, it should check the type of the value, and if the value is object, call isEquivalent itself.