I was surfing on the web in search of a shorthand Javascript notation for an if-statement. ONLY the if, not the else. My question: does it exist? eg:
(i === 0) ? onlyMyTrueValue;
The only snippet I seem to find is this one:
(i === 0) ? myTrueValue : myFalseValue;
You can do:
(i === 0) && onlyMyTrueValue;
The right hand side of the above statement will execute only if the left hand side passes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With