I would like to know if this is the best way to approach this javascript problem. I would like to first detect if a variable is undefined. If it is not, I would like to insert a default value.
Example, This if statement is receiving a variable called zoomControl. It can have 3 possible values. true, false, or undefined.
I would like the output to be: true = true, false = false, undefined = true
if (opt.set_zoomControl) {
set_zoomControl = opt.set_zoomControl
} else {
set_zoomControl = true;
}
Is this efficient? Can this be shorted or rewritten?
thank you.