Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple actions within short hand javascript

Hi I am wondering if there is a good way to run multiple functions or methods if a condition is met within short-hand javascript.

I have tried this, but doesn't work:

!gameView?launchFull(); alert('action 2'):returnView();
like image 461
codelove Avatar asked Feb 03 '26 22:02

codelove


1 Answers

Can you do it? Yes.
Working example

var x = true;
!x?(alert('true 1'),alert('true 2')):(alert('false 1'),alert('false 2'));

Note brackets around the sections.

But, should you do it? no.

like image 82
Paul S. Avatar answered Feb 06 '26 11:02

Paul S.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!