Default and Rest Parameters
Default values fill missing arguments. Rest parameters gather the remaining arguments into an array.
Example
function greet(name = "friend", ...extras) {
return `Hello ${name} +${extras.length}`;
}
console.log(greet(), greet("Ada", 1, 2));Exercise
Gather the rest.
function f(a, b) {}
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.