javascript es6 array feature […data, 0] “spread operator”

...list is using the spread syntax to spread the elements of list. Let’s assume the list is [1, 2, 3]. Therefore [...list, 0] becomes:

[1, 2, 3, 0]

Which has the same result as doing list.concat([0]);

This is not a feature of the array in ES6, it’s just been used for array concatenation. It has other uses. Read more on MDN, or see this question.

Leave a Comment