Create Map object from single list - Node.js Object

Node.js examples for Object:Object Operation

Description

Create Map object from single list

Demo Code



/**/*from  w  w w  .  j a v a 2  s . c o  m*/
 * Create Map object from single list
 *
 * @param  {Array} list
 * @return {Object}
 */
function arrayToMap(list) {
  var map = {}
  for (var i = 0; i < list.length; i++) {
    map[list[i]] = list[i]
  }
  return map
}

Related Tutorials