I have an array   prototype What is the best way to achieve the goal of using it?  ['red', 'green', 'blue']   
  {' red ': true'  
Just rearrange the array and then create hash:
  Obj = {}; (Var i = 0, l = colors.length; i & lt; l; i ++) {obj [color [i]] = true; } Has hash = new hash (obje);   You can also create a new hash object from the beginning:
  var hash = new hash (); (Var i = 0, l = colors.length; i & lt; l; i ++) {hash.Set (color [i] is true); }   I recommend
Comments
Post a Comment