Javascript Array equals(that)

Description

Javascript Array equals(that)


/**/*from w ww .j  a  v a 2s .  c o  m*/
 Only used during tests.
*/

"use strict";

if(Array.prototype.equals) {
 throw Error("Array.prototype.equals already exists");
}

Array.prototype.equals = function(that) {
 if(!Array.isArray(that)) {
  return false;
 }
 if(this.length !== that.length) {
  return false;
 }
 for(var i = 0; i < this.length; i++) {
  if(this[i] !== that[i]) {
   return false;
  }
 }
 return true;
};



PreviousNext

Related