Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

create object javascript dynamically

const list = [['one',1],['two',2], ['three', 3]];
const obj = {};
list.forEach(e => {
	obj[e[0]] = e[1];
})
console.log(JSON.stringify(obj,undefined,4))

/* Result
{
    "one": 1,
    "two": 2,
    "three": 3
}
*/
 
PREVIOUS NEXT
Tagged: #create #object #javascript #dynamically
ADD COMMENT
Topic
Name
5+5 =