Spread syntax with arrays
basically
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 apply
)
Links
Required Knowledge
- `const` declaration (Block scope)
- array (Destructuring)
- with destructuring (Rest operator)
Related Katas
Unary Operators
Bitwise Shift Operators
Rest operator
Spread operator
- with arrays
- with strings
Difficulty Level
INTERMEDIATE
First Published
10 April 2015
Stats
7 tests to solve