Search
 
SCRIPT & CODE EXAMPLE
 

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":{}}}} 
Comment

PREVIOUS NEXT
Code Example
Javascript :: dynamic classname react 
Javascript :: web storage api 
Javascript :: create object javascript 
Javascript :: dynamic useState in react 
Javascript :: chart js 
Javascript :: add select option jquery 
Javascript :: javascript promise with ajax 
Javascript :: scroll to div bottom 
Javascript :: javascript map method 
Javascript :: try without catch 
Javascript :: req is not defined 
Javascript :: how to make chrome extension js 
Javascript :: javascript create array 
Javascript :: npm font awesome angular 12 
Javascript :: web animation api keyframe options 
Javascript :: Iterating or loop through the elements of an array is with a for loop (for): 
Javascript :: charat javascript 
Javascript :: interval manage for javascript 
Javascript :: anonymous function parameters javascript 
Javascript :: mongoose create text index to search for text 
Javascript :: get last element from array javascript 
Javascript :: js object destructuring 
Javascript :: javascript date timezone 
Javascript :: remove element json javascript 
Javascript :: how many else statements can be added in javascript 
Javascript :: javascript static class variable 
Javascript :: JavaScript Access Elements of an Array 
Javascript :: bot react message with custom emoji 
Javascript :: js react 
Javascript :: console.log is not a function 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =