Javascript Array equals(otherArray)

Description

Javascript Array equals(otherArray)


// Simple compare function of two arrays
Array.prototype.equals = function(otherArray) {
  if (this.length !== otherArray.length) {
    return false;
  }//from  ww w . j a va  2  s.  c  o m
  for (var i = 0; i < this.length; i++) {
    if (this[i] !== otherArray[i]) {
      return false;
    }
    return true;
  }
};



PreviousNext

Related