paint-brush
Understanding Nullish Coalescing (or ??) in Javascriptby@smpnjn
368 reads
368 reads

Understanding Nullish Coalescing (or ??) in Javascript

by Johnny Simpson3mJuly 12th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

In Javascript, the nullish coalescing operator is used to return the right hand side whenever the left hand side is `null` or 'undefined` It is also possible to chain it with the logical OR (`||`) operator. The logical OR operator returns a value if the first value on the left doesn't meet certain criteria. However, the '||' operator returns the right side if the value is falsy - and there are a lot of falsy values in Javascript. The '??' operator is useful in situations where something can be returned as either 'null' or `undefined'

Coin Mentioned

Mention Thumbnail
featured image - Understanding Nullish Coalescing (or ??) in Javascript
Johnny Simpson HackerNoon profile picture
Johnny Simpson

Johnny Simpson

@smpnjn

Product, Engineering, Web

About @smpnjn
LEARN MORE ABOUT @SMPNJN'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Johnny Simpson HackerNoon profile picture
Johnny Simpson@smpnjn
Product, Engineering, Web

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Coffee-web
Trendcdn
Trendradars