EN
JavaScript - how to pass unspecified number of arguments to an arrow function
3
points
In this article we would like to show you how to pass unspecified number of arguments to an arrow function in JavaScript.
Below example presents how to do this using spread syntax (...
).
That syntax let's programmer to use all function arguments like array of arguments.
// ONLINE-RUNNER:browser;
const printLog = (...args) => {
for (let i = 0; i < args.length; ++i) {
console.log(args[i]);
}
};
printLog('a', 'b', 'c');