Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript Spread Operator with Object

const obj1 = { x : 1, y : 2 };
const obj2 = { z : 3 };

// add members obj1 and obj2  to obj3
const obj3 = {...obj1, ...obj2};

console.log(obj3); // {x: 1, y: 2, z: 3}
 
PREVIOUS NEXT
Tagged: #javascript #Spread #Operator #Object
ADD COMMENT
Topic
Name
6+7 =