Javascript Array map(func)

Description

Javascript Array map(func)


Array.prototype.map = function(func) {
  var results=[];

  this.forEach(function(value){

    results.push(func(value));// ww w .ja  va2s . com

  });

  return results;
};

array.map(function(value){
  return value.symbol

});

Javascript Array map(func)

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



PreviousNext

Related