Using ternary operator in JavaScript to call two functions

Can this be done in JavaScript?

type == 1 ? function1() : function2(); 
+16
javascript ternary-operator
Oct 31 '09 at 17:34
source share
2 answers

Yes, this is a valid code. It will call either function1() or function2() , but not both, depending on the value of type .

+24
Oct 31 '09 at 17:38
source share

It will not call two functions. It will call one of your two functions.

+5
Oct 31 '09 at 17:38
source share



All Articles