Created
July 17, 2013 12:14
-
-
Save zykadelic/6020024 to your computer and use it in GitHub Desktop.
See if two different objects have identical key-value pairs
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 equalObjects(object, otherObject){ | |
var objects = [object, otherObject]; | |
for(var i = 0; i < objects.length; i++){ | |
for(key in objects[i]){ | |
var isUnequalObject = typeof(object[key]) === 'object' && !equalObjects(object[key], otherObject[key]); | |
if(!object || !otherObject || isUnequalObject || object[key] !== otherObject[key]){ | |
return false; | |
} | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment