Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isEqual(obj1, obj2) {
- for (var i in obj1) {
- if (obj1.hasOwnProperty(i)) {
- if (obj2[i] !== obj1[i]) {
- return false;
- }
- }
- }
- // No need for any else clause there, since any code after a return statement won't be executed.
- return true;
- }
- // Console
- >>> isEqual({a: 1}, {a : 1})
- true
- >>> isEqual({}, {})
- true
- >>> isEqual({a: 1, b: 2}, {b: 2, a: 1})
- true
Add Comment
Please, Sign In to add comment