Deep comparison of objects/arrays [duplicate]
Update: In response to the comments and worries surrounding the original suggestion (comparing 2 JSON strings), you could use this function: function compareObjects(o, p) { var i, keysO = Object.keys(o).sort(), keysP = Object.keys(p).sort(); if (keysO.length !== keysP.length) return false;//not the same nr of keys if (keysO.join(”) !== keysP.join(”)) return false;//different keys for (i=0;i<keysO.length;++i) { if … Read more