Javascript – omit the else in an inline javascript if statement

javascript

I'm trying to use this and it doesn't appear to be working. I'm guessing it's just not an option, but want to confirm. Is this valid?

(if_it_is) ? thats_cool();

Best Answer

You can use && there:

if_it_is && thats_cool();

It is basically equal to:

if (your_expression){
   thats_cool();
}