const myFunction = (str, id=0) => { console.log(str, id) } myFunction("Hello Grepper") // OUTPUT : "Hello Grepper 0" myFunction("HG", 10) // OUTPUT : "HG 10"
let variableToSet = checkedValue || defaultValue;
function func(arg, optArg = "defualtValue") { console.log(arg, optArg); } func("A", "B"); //output "A", "B" func("Test"); //output "Test", "defaultValue" func(); //output undefined, "defualtValue"