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
Post a Comment