Javascript String map( fn )

Description

Javascript String map( fn )

String.prototype.map = function( fn )
{
    return fn( this );
};

Javascript String map(func)

String.prototype.map = function(func) { 
  var str = this.split("");
  var ans = [];/* www.j av a 2 s.  co m*/
  str.forEach(function(x) {
    ans.push(func(x));
  });
  return ans;
};



PreviousNext

Related