What I want is like this, A && B && (return false).
I can do assignment, logical calculation, calling a method or invoking a function, but just can't return false.
I know that using if then everything is ok, and just wanna know whether short circuit can do it.
I've tried eval('return false'),but got an error,Uncaught SyntaxError: Illegal return statement.
Anyone can help me?
Upadte :
Well, what I want is just to replace
if(A)
if(B)
C;
with
A && B && C;
But if C is return false , I got an error.I don't know why.And now I think if else is easier to use and understand, so I'll try it later on. And thanks for all guys commented and answered.
A && B &&and just have false?if(A && B) { return false; }?eval('return false')throws an error because it is evaluated as a single statement in a new (essentially global) execution context wherereturncan only occur in a function context.