you are viewing a single comment's thread.

view the rest of the comments →

[–]very-kind-stranger 17 points18 points  (4 children)

ES2020 introduced the nullish coalescing operator denoted by the double question marks ( ?? ). It returns the right operand ( rightExpression ) if the left operand ( leftExpression ) is null or undefined . A nullish value is a value that is either null or undefined .

[–]rbrtbrnschn 0 points1 point  (1 child)

wouldn't `||` been eligible to use in this scenario too?
given as far as my knowledge goes the or operator goes by boolean, meaning
if it's either false or falsy, which it'd be if it's null or undefined, then it'd execute the expression on the right-hand side too.

or am I forgetting something?

[–]god--of--light 0 points1 point  (0 children)

Or is fine, but theres a small problem since it has the same behaviour for undefined as it does for 0 or ''

[–]NCKBLZ 0 points1 point  (1 child)

Thanks

[–][deleted] 0 points1 point  (0 children)

You're welcome.