function check(a, b = 0) {
document.write("Value of a is: " + a +
" Value of b is: " + b +
"<br>");
}
check(9, 10);
check(1);
const myFunction = (str, id=0) => {
console.log(str, id)
}
myFunction("Hello Grepper")
// OUTPUT : "Hello Grepper 0"
myFunction("HG", 10)
// OUTPUT : "HG 10"
// 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"
}
const db = { input() { return { query() { return 'db.input(...).query(...)'; } } }, query() { return 'db.query(...)'; } };
console.log((true ? db.input() : db).query());
console.log((false ? db.input() : db).query());