Guest User

Untitled

a guest
Jun 25th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. /**
  2. * #learnjs
  3. * Find and remove an element from an array #learnjs
  4. */
  5. Array.prototype.remove = function (item) {
  6. var pos = this.indexOf(item);
  7. if (pos != -1) {
  8. this.splice(pos, 1);
  9. }
  10. }
  11. ['one', 'two', 'three', 'four', 'five'].remove('three');
  12. // result = ['one', 'two', 'four', 'five']
Add Comment
Please, Sign In to add comment