Created
March 29, 2016 12:43
-
-
Save amodig/2bbc5a1dbd021b3a2aba to your computer and use it in GitHub Desktop.
JS deep equal
This file contains 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
function deepEqual(o1, o2) { | |
if (typeof(o1)=="object" && typeof(o2)=="object" && o1 != null && o2 != null) { | |
for (var prop in o1) { | |
if (o1[prop] && o2[prop]) { | |
if (!deepEqual(o1[prop], o2[prop])) { | |
return false; | |
} | |
} | |
} | |
return true; | |
} | |
else if (o1===o2) | |
return true; | |
else | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment