Takes an array, and turns it into the truth map - Node.js Data Structure

Node.js examples for Data Structure:Map

Description

Takes an array, and turns it into the truth map

Demo Code

//takes an array, and turns it into the truth map (item[i] => true)
Object.TruthMap = function ( props ) {
  return ( props || [] ).reduce( assignTrue, Object.create(null) );

  function assignTrue ( ret, key ) {
    ret[ key ] = true;/*from   w w w  .  j  a  v  a2  s  .  c  om*/
    return ret;
  }
};

Related Tutorials