Javascript Array removeElement(from, to)

Description

Javascript Array removeElement(from, to)


'use strict';//from  w ww  .  j  a  v a2s.  c  om

Array.prototype.removeElement = function (from, to) {
  const rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  this.push(...rest);
  return this;
};



PreviousNext

Related