Evan Burbidge
Sep 29, 2023

While I agree it is handy to have a default value the case presented here I'd prefer the && operator to the ternary as both would achieve the same result. The ternary is less readable, you also hit the issue where if you need nested ternaries then you're running into the same problems, and probably somethings gone wrong.

I do like the or approach though! that would be handy for welcome messages and other things that require a default value.

Evan Burbidge
Evan Burbidge

Written by Evan Burbidge

Javascript developer specialising in React, Vue and NodeJS. I like SQL and NoSql depends on the context really!

No responses yet