3 ms·
>You can not use if "statements" as expressions in Javascript (which sucks quite a bit). It does indeed, and it leads to some ugly code: a = function() { if(1
by fnovd 10y ago
>You can not use if "statements" as expressions in Javascript (which sucks quite a bit).
It does indeed, and it leads to some ugly code:
a = function() { if(1>0) { return "Yay" } else { return "Nay" } }()
- ziad-saab 10y agoYou can also write: a = 1 > 0 ? "Yay" : "Nay"