In the code at our company i see the following.
if (someStuff != null) {
if (someStuff != "") {
doThatThing ();
}
}
While it's fully correct and valid, i'd like to rewrite it
as follows.
if (someStuff != null && someStuff != "")
doThatThing ();
I know that some languages will evaluate the first condition
of the conjunction and, provided that it fails, conclude
that the statement is not to be performed. I'd like to
assume so in this case as well, but wishing not to show
arrogance and know-better-ism, i'd like to check with more
experienced programmers first.
Will JS evaluate the whole konjunction or will it be
intelligent enough to stop as the first partial condition
fails? Is it depending on the platform used?
--
Regards
Konrad Viltersten
if (someStuff != null) {
if (someStuff != "") {
doThatThing ();
}
}
While it's fully correct and valid, i'd like to rewrite it
as follows.
if (someStuff != null && someStuff != "")
doThatThing ();
I know that some languages will evaluate the first condition
of the conjunction and, provided that it fails, conclude
that the statement is not to be performed. I'd like to
assume so in this case as well, but wishing not to show
arrogance and know-better-ism, i'd like to check with more
experienced programmers first.
Will JS evaluate the whole konjunction or will it be
intelligent enough to stop as the first partial condition
fails? Is it depending on the platform used?
--
Regards
Konrad Viltersten
Comment