Skip to content

Instantly share code, notes, and snippets.

@zykadelic
Created July 17, 2013 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zykadelic/6020024 to your computer and use it in GitHub Desktop.
Save zykadelic/6020024 to your computer and use it in GitHub Desktop.
See if two different objects have identical key-value pairs
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