Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add object to object dynamically

const b = 'b';
const c = 'c';

const data = {
    a: true,
    [b]: true, // dynamic property
    [`interpolated-${c}`]: true, // dynamic property + interpolation
    [`${b}-${c}`]: true
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #object #object #dynamically
ADD COMMENT
Topic
Name
3+5 =