Answer the question
In order to leave comments, you need to log in
How to set default value to true/false?
How to set the default value of a variable if it is boolean?
Is it possible to do this through ||
some tricky way or do I need to carry out some additional check?
function myFn(a) {
var b = a || true;
console.log(b);
}
myFn(false); //true
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question