Javascript Array trimSide()

Description

Javascript Array trimSide()

Array.prototype.trimSide = function() {
  let newArray = this.slice();

  for (i = 0; i < this.length; i++) {
    if (this[i] == '') {
      newArray.shift();/*from  w  w  w .  j a  va 2s. c o m*/
    } else {
      break;
    }
  }

  return newArray;
}



PreviousNext

Related