DEV Community

Discussion on: 5 Uses for the Spread Operator

Collapse
 
docx profile image
Lukáš Doležal • Edited

Maybe you could actually use the spread to start with default values and override with initVar:

const { aaa: { bbb, ccc } } = {
  aaa: { 
    bbb: "default bbb", 
    ccc: "default ccc", 
    ...(initVar && initVar.aaa) 
  }
}

But not sure if that is really useful in maybe more complex deconstructions? :D