Javascript Array clean()

Description

Javascript Array clean()


Array.prototype.clean = function() {
 for(let i = 0; i < this.length; i++) {
  if(this[i] === "") {
   this.splice(i, 1);//from ww  w  .jav  a2 s  .  c  o m
  }
 }
 return this;
};

Javascript Array clean()


/**//w  ww.  j  a  v  a  2s . c o m
 * Array extensions
 */

Array.prototype.clean = function clean() {
  return this.filter(function(item){ return item });
};



PreviousNext

Related