Skip to content

Instantly share code, notes, and snippets.

@why404
Created November 10, 2010 06:19
Show Gist options
  • Save why404/670443 to your computer and use it in GitHub Desktop.
Save why404/670443 to your computer and use it in GitHub Desktop.
Compare two JavaScript objects
function isEqual(a,b)
{
var c = typeof(a);
var d = typeof(b);
if (c != d) return false;
if (c != "object") return a == b;
var m = 0, n = 0;
for (var e in a)
{
m += 1;
if (b[e] == undefined) return false;
if (!isEqual(a[e],b[e])) return false;
}
for (var e in b) n += 1;
return m == n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment