pkmnq @pkmnq

i mean, just its name is cool enough, “Nullish Coalescing”

gilbert189 @gilbert189

javascript’s ?? is cool

Sep 19, 2022, 8:53 AM
0
Sep 20, 2022, 3:29 AM
5

comments

what does that do

Here’s an example:

> 1 ?? 0
1
> undefined ?? 0
0
> bork ?? 0 // bork is not defined
0

wait, the last one isn’t correct, I think I’ve confused it with an object :P

return the left argument, unless the left argument is undefined or null, in which case return the right argument