A question about JavaScript
黄舟
黄舟 2017-05-18 10:48:39
0
3
602

(a==b)&&(return a)
Lazy people want to use short-circuit operation, but the result is an error, syntax error, unexpected token return

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
漂亮男人

JavaScript logical AND operation, if the previous expression is true, then the value of the second expression is returned.

However, the return value of the expression return a is an "Illegal return statement", that is to say, it neither returns undefined, nor null or empty value, but should not return anything at all. Therefore, an error will be reported.

为情所困

Can return be placed in an expression?

PHPzhong

return a==b?a:undefined

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template