short circuit with a return statement
问题 As far as I understand, short-circuiting with the logical AND && operator works like the following: Assuming I have the expressions a and b then a && b is the same as a ? b : a since if a is truthy then the result will be b and if a is falsy then the result will be a (without even trying to resolve b ) That being the case why is the following (demo) code throwing a SyntaxError: var add = function(a,b) { b && return a+b; // if(b) return a+b ... } Is there a way to short circuit with a return