开发者

Using ternary operator in JavaScript to invoke two functions

开发者 https://www.devze.com 2022-12-09 18:58 出处:网络
Can this be done in JavaScript? type开发者_Python百科 == 1 ? function1() : function2(); Yes, that\'s valid code. It will invoke either function1() or function2(), but not both - depending on the valu

Can this be done in JavaScript?

type开发者_Python百科 == 1 ? function1() : function2();


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号