ES6 – Rest parameter

Hi, the rest parameter syntax is “…” and is an Array type, the rest parameter contains the rest of the parameters of a function when number of arguments exceeds the number of named parameters.
Here an example of how use the rest parameter:
// myFunction that receive multiple arguments
const myFunction = (a, b, c, ...args) => { // rest parameter
console.log("args --->", args);
};
// Calling myFunction and passing multiple parameters
myFunction(100, 200, 300, 400, 500, 600, 700);
Result:

Ok, maybe you are asking yourself: “…” is called Spread Operator or Rest parameter? well, is called as Spread operator or rest parameter depending on where and how it’s used.
You can read my other posts 🙂
By Cristina Rojas.