Skip to content

Instantly share code, notes, and snippets.

@desaperados
Created May 26, 2010 16:18
Show Gist options
  • Save desaperados/414701 to your computer and use it in GitHub Desktop.
Save desaperados/414701 to your computer and use it in GitHub Desktop.
// If you need to be able to compare Arrays this is the prototype to do it. Pass an Array you
// want to compare and if they are identical the method will return true. If there's a
// difference it will return false. The match must be identical so '80' is not the same as 80.
Array.prototype.compare = function(testArr) {
if (this.length != testArr.length) return false;
for (var i = 0; i < testArr.length; i++) {
if (this[i].compare) {
if (!this[i].compare(testArr[i])) return false;
}
if (this[i] !== testArr[i]) return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment