Skip to content

Instantly share code, notes, and snippets.

@simondell
Created March 4, 2013 10:03
Show Gist options
  • Save simondell/5081213 to your computer and use it in GitHub Desktop.
Save simondell/5081213 to your computer and use it in GitHub Desktop.
A shallow object similarity checker. Not revolutionary, or even that good..
function isSimilar( o1, o2 ) {
var similar = true,
prop = null;
for( prop in o1 ) {
if ( o1.hasOwnProperty( prop ) ) {
similar &= ( o2.hasOwnProperty( prop ) && o1[prop] === o2[prop] );
} else {
return false;
}
}
return similar;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment