Using the Rest Parameter and Default Arguments
Learn how to use the rest parameter and default arguments in arrow functions.
Using the rest parameter
In the Using the Rest Parameter lesson, we saw how functions can take a rest parameter. Arrow functions’ parameters can also have a rest parameter.
Let’s create an arrow function, greet()
, that takes multiple subjects.
Press + to interact
'use strict';//START:CODEconst greet =(message, ...subjects) => console.log(message + ' '+ subjects.join(', '));greet('Hi', 'Developers', 'Geeks');//END:CODE
Explanation
-
The function takes two parameters: ...