Я надеюсь, что приведенный ниже фрагмент поможет лучше понять проблему.
Я надеюсь, что это решит проблему.
function foo(val) {
if(val === undefined) {
val = false;
}
console.log("initial value of variable val =>", val)
}
//it can be often shortened to something like:
function bar(name) {
name = name || 'Bob';
console.log("initial value of variable name =>", name)
}
//The above is true for ECMAScript <= 5. and also if you use chrome <49 there is issue.
//ES6 has proposed Default parameters. So the above could be re written as
function zoo(status = 'Checked') {
console.log(" initial value of variable status =>", status)
}
foo();
bar();
zoo();