njs icon indicating copy to clipboard operation
njs copied to clipboard

add the spread operator: object literals

Open drsm opened this issue 6 years ago • 0 comments

> console.log({ a: 1, ...{ a: 2, b: 2}, b: 3 })
{ a: 2, b: 3 }
undefined
> console.log({ ...'it is funny' })
{ '0': 'i',
  '1': 't',
  '2': ' ',
  '3': 'i',
  '4': 's',
  '5': ' ',
  '6': 'f',
  '7': 'u',
  '8': 'n',
  '9': 'n',
  '10': 'y' }
undefined
> console.log({ ...[1,2,3] })
{ '0': 1, '1': 2, '2': 3 }

https://github.com/tc39/proposal-object-rest-spread/blob/master/Spread.md

drsm avatar Feb 13 '19 11:02 drsm