可以用JavaScript完成吗?
type == 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.