Using ternary operator in JavaScript to invoke two functions

前端 未结 2 1417
深忆病人
深忆病人 2020-12-03 10:47

Can this be done in JavaScript?

type == 1 ? function1() : function2();
相关标签:
2条回答
  • 2020-12-03 10:59

    Yes, that's valid code. It will invoke either function1() or function2(), but not both - depending on the value of type.

    0 讨论(0)
  • 2020-12-03 11:17

    It won't invoke two functions. It will invoke one of your two functions.

    0 讨论(0)
提交回复
热议问题