Skip to content

Instantly share code, notes, and snippets.

@ahmehri
Created May 28, 2018 09:34
Show Gist options
  • Save ahmehri/b66b849efb71179f4352032876bfe22d to your computer and use it in GitHub Desktop.
Save ahmehri/b66b849efb71179f4352032876bfe22d to your computer and use it in GitHub Desktop.
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