Skip to content
Advertisement

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

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?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement