3 ms·
Agreed. His statement is based on opinion, nothing objective. I could argue that in languages like C# the coalesce operator '??' has a similar meaning, so it is
by pweissbrod 11y ago
Agreed. His statement is based on opinion, nothing objective. I could argue that in languages like C# the coalesce operator '??' has a similar meaning, so it is intuitive for people who know C# concepts.
- MichaelGG 11y agoC#'s coalese only works on null. The problem is that JS will apparently see an empty string or 0, and consider that null. So if your function passes those values deliberately, the || trick breaks. So long you're OK with that, it seems like a clean solution. It's JavaScript. There's tons of dumb stuff a JS coder must learn. If he's confused by || then he's likely to be unable to work on any real JS.