I am using &&
like this and it works
typeof foo === \'function\' && foo(); //if foo exist then call it
instead
In the background there is a bit more with the &&
thingy, but for 99% of the cases it is perfectly fine to do it that way, just like this one.
Now as a personal opinion, for a one-liner I prefer it the &&
way instead of the if
one, because I can't stand if
keyword without a block below it hehe.
If you know what you are doing, linters are too picky sometimes.