js function args code example
Example 1: javascript function variable arguments
function foo() {
for (var i = 0; i < arguments.length; i++) {
console.log(arguments[i]);
}
}
foo(1,2,3);
//1
//2
//3
Example 2: *args python javascript equivalent
//spread operator
a = [1, 2, 3]
function printArgs(args) {
console.log(...args)
}
printArgs(a)
//=> 1 2 3