I use the ternary operator but often want to check things without an else clause. I'm wondering if there's any short way to omit this.
I've found that
a ? b : {}
works as a replacement of if (a) {b}
, saving 2 characters, but not
a ? b :
which I guess does makes sense, it being a ternary operator.
My only thought is that those empty curly brackets are a bit unsightly and is there any other way to specify a blank :
statement?
Alternatively, is there a binary ?
operator? I've rummaged in the spec but can't see how I'd use a binary logical operator, and I guess that's what if
is for.
Is there some way to use a binary logical operator to express a conditional or shorthand for {} ? I know this is probably the height of laziness for 3 characters but I'm just curious if anyone has any tricks to share.