Nodejs Array Map map(func)

Here you can find the source of map(func)

Method Source Code

Array.prototype.map = function(func){
  var result = [];
  forEach(this, function (element) {
    result.push(func(element));//from w  ww . j a  va 2s  .  c om
  });
  return result;
}

Related

  1. map(fn,thisObj)
    if(!Array.prototype.map) {
    Array.prototype.map = function(fn,thisObj)
      var scope = thisObj || window;
      var a = [];
      for(var i=0, j=this.length; i < j; ++i) {
        a.push(fn.call(scope,this[i],i,this));
      return a;
    ...
    
  2. map(from, to)
    Array.prototype.map = function(from, to) {
        var newArray = [];
        for (var i = 0; i < this.length; i++) {
            if (this[i][from] != undefined && this[i][to] != undefined) {
                newArray[this[i][from]] = this[i][to];
        return newArray;
    };
    ...
    
  3. map(fun /*, thisp*/)
    Array.prototype.map = function(fun ) {
        var len = this.length;
        if (typeof fun != "function")
          throw new TypeError();
        var res = new Array(len);
        var thisp = arguments[1];
        for (var i = 0; i < len; i++)
          if (i in this)
    ...
    
  4. map(fun /*, thisp*/)
    Array.prototype.map = function(fun ) {
        var len = this.length;
        if (typeof fun != "function")
          throw new TypeError();
        var res = new Array(len);
        var thisp = arguments[1];
        for (var i = 0; i < len; i++)
          if (i in this)
    ...
    
  5. map(fun /*, thisp*/)
    Array.prototype.map = Array.prototype.map || function(fun ) {
        var len = this.length >>> 0;
        if (typeof fun != "function") {
            throw new TypeError();
        var res = new Array(len);
        var thisp = arguments[1];
        for (var i = 0; i < len; i++) {
            if (i in this) {
    ...
    
  6. map(func)
    Array.prototype.map = Array.prototype.map || function (func) {
        array = [];
        utility.scan(this, function (item) { array.push(func(item)); });
        return array;
    };
    
  7. map(func)
    Array.prototype.map = function(func) {
      var results = [];
      for(var i = 0; i < this.length; i++) {
        var result = func(this[i]);
        results.push(result);
      return results;
    
  8. map(func)
    Array.prototype.map = function(func) {
        var length = this.length;
        var result = [];
        for ( var i = 0; i < length; i++ ) {
            result.push( func(this[i]) );
        return result;
    };
    
  9. map(grade)
    var school = [1, 2, 3, 4, 5, 6, 7, 8, 3, 35, 3, 5];
    Array.prototype.map = function(grade) {
      var result = [];
      this.forEach(function(item) {
        result.push(grade(item));
      });
      return result;
    };
    var a = school.map(function(x) {
    ...