Created
January 18, 2016 22:31
-
-
Save gabrieljmj/c6a64ed8aab9e409c1d8 to your computer and use it in GitHub Desktop.
compare arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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