Remove item from array


/ Published in: JavaScript
Save to your folder(s)

Remove the item from the array changing the length of the array.


Copy this code and paste it in your HTML
  1. Array.prototype.remove = function(e) {
  2. var t, _ref;
  3. if ((t = this.indexOf(e)) > -1) {
  4. return ([].splice.apply(this, [t, t - t + 1].concat(_ref = [])), _ref);
  5. }
  6. };

URL: http://stackoverflow.com/questions/4825812/clean-way-to-remove-element-from-javascript-array-with-jquery-coffeescript

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.