Skip to content

Instantly share code, notes, and snippets.

@arn-e
Created November 12, 2012 07:42
Show Gist options
  • Select an option

  • Save arn-e/4058022 to your computer and use it in GitHub Desktop.

Select an option

Save arn-e/4058022 to your computer and use it in GitHub Desktop.
myArray = [1,2,3,4,5];
mySecondArray = [1,2,3,4,5];
myThirdArray = [1,2,3,9,5];
Array.prototype.isEqualTo = function ( compareTo ) {
if ( this.length !== compareTo.length ) return false;
for ( var i = 0; i < this.length; i ++ ){
if ( this[i] !== compareTo[i] ) return false;
}
return true;
}
console.log(myArray.isEqualTo(mySecondArray));
// true
console.log(myArray.isEqualTo(myThirdArray));
// false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment