Spread operator Spread

Array Expansion

#with array extension

const users = [
  ...admins,
  ...editors,
  'rstacruz'
]

#No array expansion

const users = admins
  .concat(editors)
  .concat([ 'rstacruz' ])

The spread operator allows you to build new arrays in the same way. See: Spread operator

Object Extensions

#with object extensions

const options = {
  ...defaults,
  visible: true
}

#No object extension

const options = Object.assign(
  {}, defaults,
  { visible: true })

The object spread operator allows you to build new objects from other objects. See: Object Spread

Comments