Please forgive my English. I am not a native speaker.
My problem arises when I write code like this
luminosity = settings.luminosity || 50;
opacity = settings.opacity || 100;
The problem is what 0should be a valid value, but it will be ignored because it 0is false in Javascript and it will set the default value to the right of ||.
Is there a way to make a correction, so it is 0not considered a lie?
I'm doing now
luminosity = "luminosity" in settings ? settings.luminosity : 50;
but I don’t like it because it takes so long.
source
share