Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js create nested object from array

var array = ['a','b','c'];
var object = {};
array.reduce((o, s) => { return o[s] = {}; }, object);
console.log(object); // {"a":{"b":{"c":{}}}} 
 
PREVIOUS NEXT
Tagged: #js #create #nested #object #array
ADD COMMENT
Topic
Name
3+4 =