Javascript Array isSame(other)

Description

Javascript Array isSame(other)


/* A file of functions that is shared among front-end and back-end code.
 * No functions need to be explicitly exported yet since functions are
 * simply added to existing core JavaScript prototypes */

/* Checks whether two arrays are equal.
 * Used to check date equality for date arrays in the log */
Array.prototype.isSame = function(other) {
  let acc = this.length == other.length;
  for (let i = 0; i < this.length; i++) {
    if (!acc) return acc;
    acc = acc && this[i] == other[i];
  }//ww w. j a  va2  s .c o  m
  return acc;
};



PreviousNext

Related