An object in JavaScript, just like everything else except primitives(int, string, Boolean) is a reference.
Having 2 different duplicate objects, means having 2 different references that point to different places within the hype.
You can implement something as simple as that, to basically iterate over all of the primitive properties of an object, and compare them one by one:
Object.prototype.equals = function(x)
{
for(p in this)
{
switch(typeof(this[p]))
{
case 'object':
if (!this[p].equals(x[p])) { return false }; break;
case 'function':
if (typeof(x[p])=='undefined' || (p != 'equals' && this[p].toString() != x[p].toString())) { return false; }; break;
default:
if (this[p] != x[p]) { return false; }
}
}
for(p in x)
{
if(typeof(this[p])=='undefined') {return false;}
}
return true;
}