Skip to content

Instantly share code, notes, and snippets.

@gabrieljmj
Created January 18, 2016 22:31
Show Gist options
  • Save gabrieljmj/c6a64ed8aab9e409c1d8 to your computer and use it in GitHub Desktop.
Save gabrieljmj/c6a64ed8aab9e409c1d8 to your computer and use it in GitHub Desktop.
compare arrays
Array.prototype.isEqual = function (arr) {
if (arr.length != this.length || !(arr instanceof Array)) return false;
for (let k = 0, len = this.length; k < len; k++) {
if (this[k] instanceof Array && arr[k] instanceof Array) {
if (!this[k].isEqual(arr[k])) return false;
} else {
if (arr[k] !== this[k]) return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment