xxxxxxxxxx
// arguments is "like" an array that stores all arguments given to manyArgs
// (User can invoke manyArgs with arguments even though none are specified)
function manyArgs() {
for (var i = 0; i < arguments.length; ++i)
alert(arguments[i]);
}
// Note: for arrow functions you must do
let manyArgs = (concreteArg1, concreteArg2, rest) => {
for (var i = 0; i < rest.length; ++i)
alert(rest[i]);
// concreteArgs are not included in rest "array"
}
xxxxxxxxxx
const myFunction = (str, id=0) => {
console.log(str, id)
}
myFunction("Hello Grepper")
// OUTPUT : "Hello Grepper 0"
myFunction("HG", 10)
// OUTPUT : "HG 10"