Can a JavaScript function take unlimited arguments? Something like this:
testArray(1, 2, 3, 4, 5...);
I am trying:
var arr
There are some legacy methods but I prefer the ES6
and newer versions, So if I wanna implement this, I wrote it like below:
const func = ...arg => console.log(arg);
Simple and cutting edge of tech.
function toArray() {
return arguments;
}
var myargs = toArray(1, 2, 3, 4, 5, 6);
The arguments
keyword is available in every js function
var arr = [];
function testArray() {
Array.prototype.push.apply(arr, arguments);
}