Convert Array to Map - Node.js Data Structure

Node.js examples for Data Structure:Map

Description

Convert Array to Map

Demo Code

Array.prototype.Map = function(func) {
    var mappedArray = new Array(this.length);
    var i;/*from ww w  .  j a va2  s  . co  m*/
    
    for (i = 0; i < this.length; i++) {
    mappedArray[i] = func(this[i]);
  }
  
  return mappedArray;
}

Related Tutorials