DEV Community

Discussion on: What’s the Ternary Operator in Javascript and How to Use it

Collapse
 
pierreatwork profile image
Pierre

Great article !

Do you know if there is any performance gain using this or is it the same as if/else ?

Thanks !

Collapse
 
alainvanhout profile image
Alain Van Hout

I have no idea about execution performance, but I know that excessive use of the ternary operator can very efficiently give you a headache 😆.

Collapse
 
gaelgthomas profile image
Gaël Thomas

Hahaha, you got it! 😆

Collapse
 
gaelgthomas profile image
Gaël Thomas

Thank you, Pierre!

I didn't test by myself, but after reading a few posts talking of that, there isn't much of a difference in performance one way or the other.

The main difference is the way to write a condition and readability.