3 ms·
The "..." is called a spread operator in javascript. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax https://develope
by manbash 4y ago
The "..." is called a spread operator in javascript.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
(In python there is the "*" operator which should be equivalent: [1, 2, *arr].
Array(clicks) instantiate an array of length 'clicks', with its elements undefined.
Then "[...Array(clicks)]" takes the above array instance and spreads it as content in another array.
Seems redundant and they could've just used Array(clicks).
- tuukkah 4y ago> Array(clicks) instantiate an array of length 'clicks', with its elements undefined. Not undefined elements but no elements, or "empty" elements. > they could've just used Array(clicks). No, because the following forEach call does nothing for such an array. You need to fill the array first with Array(clicks).fill() or shorter, [...Array(clicks)]