Object.equal = function( firstObj, secondObject ){
var keysFirstObj = Object.keys( firstObj );
var keysSecondObject = Object.keys( secondObject );
if ( keysFirstObj.length != keysSecondObject.length ) {
return false;
}
return !keysFirstObj.filter(function( key ){
if ( typeof firstObj[key] == "object" || Array.isArray( firstObj[key] ) ) {
return !Object.equal(firstObj[key], secondObject[key]);
} else {
return firstObj[key] !== secondObject[key];
}
}).length;
}
alert(Object.equal({a:[1,2,{b:1}], c: {d:[1,2,3]}},{a:[1,2,{b:1}], c: {d:[1,2,3]}}));