Created
May 28, 2018 09:34
-
-
Save ahmehri/b66b849efb71179f4352032876bfe22d to your computer and use it in GitHub Desktop.
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
const _ = require('lodash'); | |
const array1 = [1, 2]; | |
const array2 = [1, 2]; | |
const result = array1 === array2; | |
result | |
console.log([] === []) | |
console.log([] == []) | |
console.log(Object.is([], [])) | |
const ref = []; | |
console.log(ref === ref) | |
console.log(ref == ref) | |
console.log(Object.is(ref, ref)) | |
const emptyArray = []; | |
console.log(emptyArray === emptyArray) | |
// good | |
console.log(_.difference([1, 2], [1, 2]).length === 0) | |
// better (deep comparison, https://lodash.com/docs/4.17.10#isEqual) | |
console.log(_.isEqual([1, 2], [1, 2])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment