Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

assign an element value as key in array of objects

var keys = ['HP', 'QP', 'PS'],
    object = Object.assign(...keys.map(key => ({ [key]: 0 })));
    
console.log(object);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #assign #element #key #array #objects
ADD COMMENT
Topic
Name
9+9 =