Skip to content

Instantly share code, notes, and snippets.

@Harrisonkamau
Created September 20, 2019 16:04
Show Gist options
  • Save Harrisonkamau/9d5701cdb8e035d44a79421f9225f81b to your computer and use it in GitHub Desktop.
Save Harrisonkamau/9d5701cdb8e035d44a79421f9225f81b to your computer and use it in GitHub Desktop.
Testing for deep equivalence between two JavaScript arrays
// let's try the old way
const arr1 = [1,2,3];
const arr2 = [1,2,3];
console.log(arr1 === arr2); // returns false
// Hello JSON.stringify()!
console.log(JSON.stringify(arr1) === JSON.stringify(arr2)); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment