This should be quite a simple question I just couldn't find the answer anywhere so thought I'd save myself some time and ask here.
I was looking at some javascript code and noticed an expression of the form:
a < b && (other maths statements);
The other maths statements are just assigning of variables and simple stuff.
My question is this. Is this another way to write compact if statements?
I know that statement?if-block:else-block; is one way to do it but as && is short-circuit and left-associative this is all I can think it would be. I know you can't have an else block with this method but it's pretty neat.
Can someone just validate I'm awake at this time in the morning please.
Thanks,
trueorfalse. It can be used in an if statement. But withoutif(a&&b)or any asignment to a variable it does nothing...if (...), if only because it prompts questions like this.