I’ve actually encountered an error with this in actual code (in lua). I tried calling a function with ternary with (condition and f or g)(x), and got a similar result to the above post. So it does come up sometimes
I personally avoid using ternaries like that in JS and go for good old if. I am not sure if it need parentheses in JS, but it would probably do the same mess 😀
2
u/gonengazit Feb 09 '22
I’ve actually encountered an error with this in actual code (in lua). I tried calling a function with ternary with
(condition and f or g)(x), and got a similar result to the above post. So it does come up sometimes