+ 2

Why does this output 'false'? Object comparison, see example...

var info1 = { "planet":"Earth", "suitable For Living":true }; var info2 = { "planet":"Earth", "suitable For Living":true }; alert(info1 === info2 || info1 == info2); gives 'false' is this because the object properties are strings which contain spaces?

13th Aug 2017, 8:37 AM
Rcknmrty
Rcknmrty - avatar
1 Resposta
+ 2
var info1 = { }; var info2 = { }; alert(info1 === info2 || info1 == info2); also gives false. it's true when i set info2 = info1; before the alert. this means that objects are always different from one another, unless i set them equal
13th Aug 2017, 9:16 AM
Rcknmrty
Rcknmrty - avatar