loading...

re: 5 Uses for the Spread Operator VIEW POST

FULL DISCUSSION
 

You can also use it to conditionally add properties to objects.

const obj = {
  a:1,
  ...true && {b:2},
  ...false && {c:3}
}

// {a:1,b:2}
Code of Conduct Report abuse