Here you can find the source of removeByValue( val )
/**// www . ja v a2s . c o m * Function to remove values from arrays * * @param {Array} this.elements or this.fields * * @returns {undefined} */ Array.prototype.removeByValue = function( val ) { for ( var i=0; i < this.length; i++ ) { if ( this[i] == val ) { this.splice( i, 1 ); break; } } };
Array.prototype.removeByValue = function(index,val) { for(var i=0; i<this.length; i++) { if(this[i][index] == val) { this.splice(i, 1); break; var arr = [{first:'zhang',last:'san'},{first:'li',last:'si'}]; ...
Array.prototype.removeByValue = function(val) { for(var i=0; i<this.length; i++) { if(this[i] == val) { this.splice(i, 1); break;
Array.prototype.removeByValue = function(value) { for (var i = 0; i < this.length; ++i) { if (this[i] == value) { this.splice(i, 1);
Array.prototype.removeByValue = function (value) { var i = 0, count = 0; for (i = 0; i < this.length; i += 1) { if (this[i] === value) { this.splice(i, 1); i -= 1; count += 1; return count; }; var fruits = ["Apple", "Banana", "Orange", "Apple", "Mango", "Apple"]; var arr = [1, 3, 1, 1, 4, 5, 8, 1]; var value; var removedElelemnts = 0; jsConsole.writeLine('array: [' + arr + ']'); value = 1; jsConsole.writeLine('remove elements with value: ' + value); removedElelemnts = arr.removeByValue(value); jsConsole.writeLine('number of removed elements: ' + removedElelemnts); jsConsole.writeLine('array: [' + arr + ']'); jsConsole.writeLine(''); jsConsole.writeLine('fruits array: [' + fruits + ']'); value = 'Apple'; jsConsole.writeLine('remove elements with value: ' + value); removedElelemnts = fruits.removeByValue(value); jsConsole.writeLine('number of removed elements: ' + removedElelemnts); jsConsole.writeLine('fruits array: [' + fruits + ']');