js function optional argument 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: javascript optional parameters
const myFunction = (str, id=0) => {
console.log(str, id)
}
myFunction("Hello Grepper")
// OUTPUT : "Hello Grepper 0"
myFunction("HG", 10)
// OUTPUT : "HG 10"