Javascript Property with three dots (...)

Solution 1:

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.

Solution 2:

The [...something] is the spread operator. It in essence allows for an array or string to be expanded. You will see it used often in React, but has many other use cases.

MDN has great documentation on the spread operator: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator

Solution 3:

... (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