how to make arguments quantity to be variable injs code example
Example 1: javascript x number of parameters
function display_numbers(...numbers) {
colors.forEach(function(x) {
console.log(x);
});
}
// call it like:
display_numbers(1)
display_numbers(1, 2, 3, 4)
display_numbers(1, -1, 9, 0, 2)
Example 2: 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