Here you can find the source of removeItem(value)
Array.prototype.removeItem = function(value) { var result = []; for (var i = 0; i < this.length; i++) { if (this[i] === value) { this.splice(i, 1);// w ww . ja v a 2s . co m } } return this; }; var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1']; var arr2 = ['hi', 'bye', 'hello']; console.log(arr.removeItem(1)); console.log(arr2.removeItem('bye'));
var arr = [1,2,1,4,1,3,4,1,111,3,2,1,'1']; Array.prototype.removeElement = function removeElement(element){ for (var i = 0; i < arr.length; i+=1) { if(arr[i]===element){ arr.splice(i,1) return arr; }; ...
Array.prototype.removeElements = function (elements) {
elements.forEach((el) => {
this.splice(this.indexOf(el), 1)
})
Array.prototype.removeItem = function (value) { for (var i in this) { if(this[i] === value){ this.splice(i, 1); return this; }; var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1']; ...
Array.prototype.removeItem = function (value) { for (i = 0; i < this.length; i++) { if (this[i] === value) { this.splice(i, 1); var arrOne = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1']; arrOne.removeItem(1); ...
Array.prototype.removeItem = function (value) { for (var i = 0; i < this.length; i++) { if (this[i] === value) { this.splice(i, 1); return this; var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1']; ...
Array.prototype.removeItem = function (value) { var result = []; for (var i = 0; i < this.length; i++) { if (this[i] === value) { this.splice(i, 1); return this; }; ...
Array.prototype.removeItem = function (value) { var len = this.length; var resultArr = []; for (var i = 0; i < len; i++) { if (this[i] !== value) { resultArr.push(this[i]); return resultArr; ...
Array.prototype.removeItem = function(value) { for (var i = 0; i < this.length; i++) { if(this[i] === value) { this.splice(i, 1); }; var arrFirst = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1']; arrFirst.removeItem(1); ...
"use script" Array.prototype.removeItem = function(value) { if(typeof value === 'number' || typeof value === 'string') { for (var index in this) { if(this[index] === value) { this.splice(index, 1); }; var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1']; arr.removeItem(1); console.log(arr); arr = ['hi', 'bye', 'hello' ]; arr.removeItem('bye'); console.log(arr);