Created
October 24, 2016 10:07
-
-
Save nobeans/206f65a88ee794b7730a323ef2e89ffc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// http://jmatsuzaki.com/archives/16866 | |
var l1 = [1, 2, 3]; | |
console.log(l1); | |
var l2 = [1, 2, 3]; | |
console.log(l2); | |
console.log(l1 == l2); // false | |
console.log(l1 === l2); // false | |
console.log(JSON.stringify(l1) == JSON.stringify(l2)); // true | |
console.log(JSON.stringify(l1) === JSON.stringify(l2)); // true | |
var obj1 = { | |
a: 1, | |
b: 2, | |
c: 3, | |
}; | |
console.log(JSON.stringify(obj1)); | |
var obj2 = { | |
a: 1, | |
b: 2, | |
c: 3, | |
}; | |
console.log(JSON.stringify(obj2)); | |
console.log(JSON.stringify(obj1) === JSON.stringify(obj2)); // true | |
var obj3 = { | |
a: 1, | |
b: 2, | |
c: 4, | |
}; | |
console.log(JSON.stringify(obj3)); | |
console.log(JSON.stringify(obj1) === JSON.stringify(obj3)); // false | |
var obj4 = { | |
a: 1, | |
b: 2, | |
}; | |
console.log(JSON.stringify(obj4)); | |
console.log(JSON.stringify(obj1) === JSON.stringify(obj4)); // false | |
var obj5 = { | |
a: 1, | |
b: 2, | |
c: "3" | |
}; | |
console.log(JSON.stringify(obj5)); | |
console.log(JSON.stringify(obj1) === JSON.stringify(obj5)); // false | |
console.log('Done'); | |
// [ 1, 2, 3 ] | |
// [ 1, 2, 3 ] | |
// false | |
// false | |
// true | |
// true | |
// {"a":1,"b":2,"c":3} | |
// {"a":1,"b":2,"c":3} | |
// true | |
// {"a":1,"b":2,"c":4} | |
// false | |
// {"a":1,"b":2} | |
// false | |
// {"a":1,"b":2,"c":"3"} | |
// false | |
// Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment