I was looking at the JavaScript console in Chrome and noticed something strange, even though they appear the same, obj and JSON.parse(JSON.stringify(obj)) are not the same. Why is that?
var obj = {test:'this is a test', another: {omg:'ay dios mio', check:true}};
console.log(obj, JSON.parse(JSON.stringify(obj)));
console.log(obj == JSON.parse(JSON.stringify(obj)));
They look identical but return false when you check equality. Why is that?
JSON.stringify()then you'll see their values are equal.[...]If both operands are objects, then JavaScript compares internal references which are equal when operands refer to the same object in memory.