Created
March 4, 2013 10:03
-
-
Save simondell/5081213 to your computer and use it in GitHub Desktop.
A shallow object similarity checker. Not revolutionary, or even that good..
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 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