I’m having trouble understanding the order in which an || is executed in Jquery/Javascript.
If I have this:
someVar = $el.attr("one") || options.two || "three";
it sets someVar to “three” when both $el.attr("one") and options.two are not defined.
I need to add another condition to this statement, like so:
someVar = $el.attr("one") || options.two || options.extra == "true" ? undefined : "three";
So this should say:
If neither '$el.attr("one")' or 'options.two' are defined, check if 'options.extra == true', if it’s true, set to 'undefined', otherwise set to 'three'.
However, I’m always getting undefined even if I set $el.attr("one") and I don’t understand why?
Can anyone tell me what is wrong in my logic?
Thanks!
I think you must put some parenthesis:
in fact your own code is read as: