Nodejs Array Remove remove()

Here you can find the source of remove()

Method Source Code

Array.prototype.remove = function() {
    const toRemove = this.shift();
    let newArr = [];//from  ww  w.j  a v a  2s .c o  m

    for(const i of this)
        if(i !== toRemove)
            newArr.push(i);

    this.splice(this);

    for(const i of newArr)
        this.push(i);
}

function solve(arr) {
    arr.remove();
    arr.forEach(x => console.log(x));
}

solve([ '1', '2', '3', '2', '1', '2', '3', '2' ]);

Related

  1. remove()
    Array.prototype.remove= function(){
        var what, a= arguments, L= a.length, ax;
        while(L && this.length){
            what= a[--L];
            while((ax= this.indexOf(what))!= -1){
                this.splice(ax, 1);
        return this;
    ...
    
  2. remove()
    Array.prototype.remove = function() {
        var what, a = arguments, L = a.length, ax;
        while (L && this.length) {
            what = a[--L];
            while ((ax = this.indexOf(what)) !== -1) {
                this.splice(ax, 1);
        return this;
    ...
    
  3. remove()
    Array.prototype.remove = function() {
        var what, a = arguments, L = a.length, ax;
        while (L && this.length) {
            what = a[--L];
            while ((ax = this.indexOf(what)) !== -1) {
                this.splice(ax, 1);
        return this;
    ...
    
  4. remove()
    Array.prototype.remove = function() {
      var what, a = arguments, L = a.length, ax;
      while (L && this.length) {
        what = a[--L];
        while ((ax = this.indexOf(what)) !== -1) {
          this.splice(ax, 1);
      return this;
    ...
    
  5. remove()
    Array.prototype.remove = function () {
        var what, a = arguments, L = a.length, ax;
        while (L && this.length) {
            what = a[--L];
            while ((ax = this.indexOf(what)) !== -1) {
                this.splice(ax, 1);
        return this;
    ...
    
  6. remove()
    Array.prototype.remove = function () {
        for (var i = 0; i < this.length; i++) {
            if (this[i] === arguments[0]) {
                this.splice(i, 1);
                i--;
    var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
    ...
    
  7. remove()
    Array.prototype.remove = function()
      for(var i = 0; i < arguments.length; i++)
        this.splice(arguments[i] ,1);
    };
    
  8. remove()
    Array.prototype.remove = function(){
        var args = [].slice.call(arguments);
        var removed = [];
        var self = this;
        var len = args.length;
        for(var i = 0; i < len; i++){
            var index;
            while((index = this.indexOf(args[i])) >= 0){
                this.splice(index,1);
    ...
    
  9. remove()
    var toRemove = 1;
    Array.prototype.remove = function () {
        for (var i in this) {
            if (this[i] === toRemove) {
                this.splice(i, 1);
    var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
    ...