spread operator merge objects 1

spread operator merge objects

 let a = {
    a: 1,
    b: true
}

let b = {
	y: 093,
	z: 'This is an object'
}

const c = {...a, ...b}

Here is what the above code is Doing:
1. We’re creating an object called a.
2. We’re creating an object called b.
3. We’re creating a new object called c.
4. We’re using the spread operator to copy the properties of a and b into c.

Similar Posts