Nodejs Array Reorder reorder(mapping)

Here you can find the source of reorder(mapping)

Method Source Code

Array.prototype.reorder = function (mapping) {
  return mapping.map(index => this[index])
}

Related

  1. reorder(a)
    Array.prototype.reorder = function (a){
      var o = [], _ = this, i = 0;
      _.forEach(function(){
        o.push(_[a[i]] ? _[a[i]] : _[i]);
      i++;
      });
      return o;
      };
    
  2. reorder(a)
    var myArray = ['one', 'two', 'three','four', 'five'];
    Array.prototype.reorder = function (a){
      var o = [], _ = this, i = 0;
      _.forEach(function(){
        o.push(_[a[i]] ? _[a[i]] : _[i]);
      i++;
      });
      return o;
    };
    ...