Last active
October 11, 2015 12:18
-
-
Save sstur/3857637 to your computer and use it in GitHub Desktop.
Check if two objects are Eql
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 isEql(a, b) { | |
if (keys(a).sort().join() !== keys(b).sort().join()) { | |
return false; | |
} | |
for (var key in a) { | |
if (a[key] !== b[key]) return false; | |
} | |
return true; | |
} | |
function keys(obj) { | |
if (Object.keys) return Object.keys(obj); | |
var arr = []; | |
for (var key in obj) { | |
if (Object.prototype.hasOwnProperty.call(obj, key)) { | |
arr.push(key); | |
} | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment