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

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -