Is ternary operator, if-else or logical OR faster in javascript?

后端 未结 7 1568
情歌与酒
情歌与酒 2020-11-30 02:06

Which method is faster or more responsive in javascript, if-else, the ternary operator or logical OR? Which is advisable to use, for what reasons?

7条回答
  •  一整个雨季
    2020-11-30 02:54

    The speed difference will be negligible - use whichever you find to be more readable. In other words I highly doubt that a bottleneck in your code will be due to using the wrong conditional construct.

提交回复
热议问题