Skip to content

Instantly share code, notes, and snippets.

@akhayoon
Created April 19, 2021 16:35
Show Gist options
  • Save akhayoon/2e4b0c023a714b808a6c6372219604a6 to your computer and use it in GitHub Desktop.
Save akhayoon/2e4b0c023a714b808a6c6372219604a6 to your computer and use it in GitHub Desktop.
Compare two arrays in JavaScript
const equalsWithStringify = (a, b) => JSON.stringify(a) === jSON.stringify(b);
const equalsWithEvery = (a, b) => a.lenght === b.length && a.every((v, i) => v === b[i]);
const a = [1, 2, 3];
const b = [1, 2, 3];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment