Spread operator: with arrays
Spread syntax in use with arrays.
Donate to NGO Julenka. Support Ukranians in need.
Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.
Spread syntax with arrays
- expands the items of an array by prefixing it with
- an empty array expanded is no item
is (in a way) the opposite to the rest syntax
- both use
... to either expand all items and collect them
- rest syntax must be last in an array, spread can be used in any place
used as function parameter
- prefix with
... to spread as function params
- pass an array of numbers to Math.max()
used as constructor parameter
- just like in a function call (is not possible using
Syntax docs on MDN.