How to add elements in an array as properties of an object in JavaScript -


Assume that I have an array:

  var member = ["Peter" , "Paul", "Mary"];  

and one object:

  var band = {};  

Is there a way to iterate through the array that each element in the member array will also be added as the value of the object as the properties of the band object?

  band = {"Peter": {}, "Paul": {}, "Mary": {}}  

< Try div class = "post-text" itemprop = "text">

:

  var member = ["Peter", "Paul", "Mary"]; Var band = {}; Member. Former (work (member) {band [member] = {};});  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -