Skip to content

Latest commit

 

History

History

nullish_coalescing

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Nullish Coalescing

Good day folks! 👋 Today, we are going to cover something small, yet, an important feature in Javascript. In this post, we will see how Nullish Coalescing or Nullish Koala-sing 🐨🎤 (whichever sounds good 😅) works using GIFs.

Note: Short-circuiting is denoted by ⚡️

Scenario 1 (Base case): If the expression at the left-hand side of the ?? operator evaluates to undefined or null, its right-hand side is returned. If the expression at the `left-hand side` of the `??` operator evaluates to `undefined` or `null`, its `right-hand side` is returned.

Scenario 2: Behavior of Nullish Coalescing ?? operator with falsy Javascript values. Behavior of Nullish Coalescing `??` operators when `falsy` Javascript values are passed

Notice how short-circuiting (denoted by ⚡️) happens when the LHS is null or undefined. It doesn't matter if the LHS is falsy values except for null and undefined

Note: Explicit parentheses groups are required to mix with || and &&

Scenario 3: When mixed with other short-circuiting operators || and && without parentheses When mixed with other short-circuiting operators `||` and `&&` *without* parentheses logical or and logical and javascript

Scenario 4: When mixed with other short-circuiting operators || and && with parentheses groups When mixed with other short-circuiting operators `||` and `&&` *with* parentheses groups

When mixed with other short-circuiting operators `||` and `&&` *with* parentheses groups

That's it for today and I hope you found it useful!

And hey, I ❤️ learning from and staying in touch with the curious folks out there (I'm looking at you. Yeah, YOU!). So, please feel free to reach out if you have any questions or suggestions 🙋‍♀️🙋‍♂️ I'm all ears 🤩

🐥Twitter 💼LinkedIn

Auf wiedersehen 🙌🏼