?? is intuitive if you (truly) understand ||
Comment on I'm creating a curated search engine for web developers. Asking for a feedback
towerful@programming.dev 11 months agoWhen you want to know the name of the operator for a language.
Like “what does & mean in c++?”.
&
isn’t too bad, but some of them can be difficult (like “JavaScript ??”).
And if you don’t know it’s called a reference operator, or a bullish coalescence operator, or whatever… Trying to learn what it does can be downright impossible
themusicman@lemmy.world 11 months ago
xmunk@sh.itjust.works 11 months ago
Yea, I don’t know why people want to learn things - it’s easier to just know them! /s
kryptonianCodeMonkey@lemmy.world 11 months ago
Have you tried divining syntaxes from reading the entrails of a sacrificed goat?
abbadon420@lemm.ee 11 months ago
It works on my machine
themusicman@lemmy.world 11 months ago
What? The previous comment said it’s “downright impossible to learn” which is nonsense.
|| means “Evaluate and use the left operand, unless it’s falsy, in which case evaluate and use the right operand instead”
?? means “Evaluate and use the left operand, unless it’s nullish, in which case evaluate and use the right operand instead”
They’re the same thing except for which values fall through to the second operand
xmunk@sh.itjust.works 11 months ago
Yea, in well aware.
But you had to learn that somewhere.
sznowicki@lemmy.world 11 months ago
For ?? I guess it already has a decent results. I’ll periodically check those kind of cases once the index gets more languages.
kukei.eu/?q=js+%3F%3F+operator