Languages
[Edit]
EN

JavaScript - how to pass unspecified number of arguments to an arrow function

3 points
Created by:
Dirask Community
3750

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');
Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join