Skip to content

Instantly share code, notes, and snippets.

@andersonbosa
Created October 29, 2020 16:47
Show Gist options
  • Save andersonbosa/f44856e8d802ccc1f18317f13eb02d53 to your computer and use it in GitHub Desktop.
Save andersonbosa/f44856e8d802ccc1f18317f13eb02d53 to your computer and use it in GitHub Desktop.
/**
* Checks whether the two lists are the same.
* @param { *[] } arrA
* @param { *[] } arrB
* @returns { Boolean }
*/
function arraysEqual (arrA, arrB) {
if (!arrA || !arrB) {
return
}
return JSON.stringify(arrA) === JSON.stringify(arrB)
}
const a = [{ answer: 42 }, { powerLevel: 9001 }];
const b = [{ answer: 42 }, { powerLevel: 9001 }];
const c = [{ answer: 42 }, { password: 'taco' }];
arrayEquals(a, b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment