Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * #learnjs
- * Find and remove an element from an array #learnjs
- */
- Array.prototype.remove = function (item) {
- var pos = this.indexOf(item);
- if (pos != -1) {
- this.splice(pos, 1);
- }
- }
- ['one', 'two', 'three', 'four', 'five'].remove('three');
- // result = ['one', 'two', 'four', 'five']
Add Comment
Please, Sign In to add comment