Last active
April 23, 2017 13:51
-
-
Save qzm/5112704fa975995a462a4ff1c232e489 to your computer and use it in GitHub Desktop.
deep equal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var deepEqual = function (x, y) { | |
if ((typeof x == "object" && x != null) && (typeof y == "object" && y != null)) { | |
if (Object.keys(x).length != Object.keys(y).length) { | |
return false; | |
} | |
for (var prop in x) { | |
if (y.hasOwnProperty(prop)) { | |
return deepEqual(x[prop], y[prop]); | |
} | |
} | |
} else if (x !== y) { | |
return false; | |
} else { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment