Skip to content

dwi-handoyo/Spread-Operator-and-Rest-Parameter

Repository files navigation

Spread-Operator-and-Rest-Parameter

Spread operator and rest parameter used same symbol, ie. triple dots (...). The main difference between rest and spread is that the rest operator puts the rest of some specific user-supplied values into a JavaScript array. But the spread syntax expands iterables into individual elements.

1. Spread Operators (...arguments)

Spread operator can be applied for

a. Break iterables into single components

b. Joining two arrays

c. Joining two arrays or more

d. Copying array

e. Transform node list into array

f. Pass an indefinite number of parameters to a function.

2. Rest Parameters (a, b, ...rest)

Rest parameter can be applied for

a. Pass an indefinite number of parameters to a function.

b. Destructuring array