javascript function args code example
Example 1: js unspecified parameters
function my_log(...args) {
// args is an Array
console.log(args);
// You can pass this array as parameters to another function
console.log(...args);
}
Example 2: *args python javascript equivalent
//spread operator
a = [1, 2, 3]
function printArgs(args) {
console.log(...args)
}
printArgs(a)
//=> 1 2 3