Here you can find the source of remove()
/*//from w w w . j a v a2 s .c o m Problem 2. Remove elements Write a function that removes all elements with a given value. Attach it to the array type. Read about prototype and how to attach methods. */ var toRemove = 1; Array.prototype.remove = function () { for (var i in this) { if (this[i] === toRemove) { this.splice(i, 1); } } } var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1']; arr.remove(toRemove); console.log(arr);
Array.prototype.remove = function () { var what, a = arguments, L = a.length, ax; while (L && this.length) { what = a[--L]; while ((ax = this.indexOf(what)) !== -1) { this.splice(ax, 1); return this; ...
Array.prototype.remove = function() { const toRemove = this.shift(); let newArr = []; for(const i of this) if(i !== toRemove) newArr.push(i); this.splice(this); for(const i of newArr) this.push(i); ...
Array.prototype.remove = function () { for (var i = 0; i < this.length; i++) { if (this[i] === arguments[0]) { this.splice(i, 1); i--; var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1']; ...
Array.prototype.remove = function() for(var i = 0; i < arguments.length; i++) this.splice(arguments[i] ,1); };
Array.prototype.remove = function(){ var args = [].slice.call(arguments); var removed = []; var self = this; var len = args.length; for(var i = 0; i < len; i++){ var index; while((index = this.indexOf(args[i])) >= 0){ this.splice(index,1); ...
Array.prototype.remove = function() { var i, j, l, m; l = arguments.length; i = 0; while (i < l) { m = this.length; j = 0; while (j < m) { if (arguments[i] === this[j]) { ...
Array.prototype.remove= function(){ if(!Array.prototype.indexOf){ Array.prototype.indexOf= function(what, i){ i= i || 0; var L= this.length; while(i< L){ if(this[i]=== what) return i; ++i; return -1; var what, a= arguments, L= a.length, ax; while(L && this.length){ what= a[--L]; while((ax= this.indexOf(what))!= -1){ this.splice(ax, 1); return this;
Array.prototype.remove = function() { var what, a = arguments, L = a.length, ax; while (L && this.length) { what = a[--L]; while ((ax = this.indexOf(what)) !== -1) { this.splice(ax, 1); return this; ...
Array.prototype.remove = function() { var count = 0; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; if (arg.constructor == Array) { for (var j = 0; j < arg.length; j++) count += this.remove(arg[j]); } else { var index = 0; ...