Javascript Property with three dots (...)

That is not ES6 but has only been added in ECMAScript 2018.

It is called "Object Rest/Spread Properties" and is part of the Spread Syntax.


... (three dots in Javascript) is called the Spread Syntax or Spread Operator. This allows an iterable such as an array expression or string to be expanded or an object expression to be expanded wherever placed.

I want to list down the mostly used practical Use Cases of the Spread Syntax (Spread Operator). The following has been explained with examples in this stackoverflow answer.

  1. Combine Arrays (Concatenate Arrays)
  2. Copying Arrays
  3. Calling Functions without Apply
  4. Destructuring Arrays
  5. Function Arguments as Rest Parameters
  6. Using Math Functions
  7. Combining Two Objects
  8. Separate a String into Separate Characters

Tags:

Javascript