DEV Community

loading...

Discussion on: How to merge two Objects or Arrays in JavaScript

Collapse
vladimirgal1012 profile image
Vladimir Gal

It is pretty useful in deconstructing too.

const a = {
   name: 'Maria',
   sureName: 'Smith',
   age: 22
}
const {name, ...rest} = a

console.log(name)
// output: 'Maria'

console.log(rest)
//output: {sureName: 'Smith', age: 22}
Collapse
dochan profile image
Farhan Yahya Author

Wow, thanks a lot