How to use function with rest parameter to accept any number of arguments as an array in JavaScript

1 Answer

0 votes
function f(...arguments) {
  document.write(arguments + "<br />");
}

f('javascript');
f('javascript', 'php');
f('javascript', 'php', 8392);



/*
run:
      
javascript
javascript,php
javascript,php,8392
    
*/

 



answered Nov 3, 2019 by avibootz
...