Array Remove

an array function that removes a single element from an array

by Nathan Woods

JavaScript

b = ['one','two','three','four','five','six','seven'];

Array.prototype.remove = function(item) {
    var i = this.indexOf(item);
    if (i!=-1) this.splice(i, 1);
};

function prettyPrint(a) {
    document.write('Length:'+a.length+' : '+a+'<br>');
};


prettyPrint(b);
b.remove('two');
b.remove('even');
prettyPrint(b);