loading...
Cover image for How To Copy Properties from an Object To Another?

How To Copy Properties from an Object To Another?

islam profile image Islam Sayed ・1 min read

Rest operator is awesome. Here is how to copy properties from one object to another using Spread operator.

//copy properties from an object to another one
//using SPREAD OPERATOR.
const obj1 = {
    a: 2,
    b: 5
}
const obj2 = {
    ...obj1,
    c: 6
} //{a: 2, b: 5, c: 6}

Discussion

pic
Editor guide