Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Array.prototype.removeItem = function () {
- for (var j = 0; j < arguments.length; j++) {
- for (var i = 0; i < this.length; i++) {
- if (this[i] === arguments[j]) {
- this.splice(i, 1);
- }
- }
- }
- return this;
- }
- var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
- arr.removeItem(1, 111);
- console.log(arr);
- arr = ['hi', 'bye', 'hello'];
- arr.removeItem('bye', 'hi');
- console.log(arr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement