DEV Community

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

Collapse
 
mrdreix profile image
Vladimír Gál • Edited

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

Wow, thanks a lot