Hi folks. I wanted to take this opportunity to talk about one of the new features of TypeScript 3.7 which, conveniently, will also be included in vanilla JavaScript.

The feature is called Nullish Coalescing and it’s summed up here by the good folks at TypeScript. But if you’re a glutton for punishment, please read on.

Nullish Coalescing#

I’m sure we’d all appreciate a bit more coalescing in the world, but for now we can settle for it in our code. Exactly what is Nullish Coalescing and why do we need it?

The answer is, it’s similar to this:

const mayBeThisThingOrThisOtherThingIfNot = thisThing || thisOtherThing
<>

but not exactly.

If you’re familiar with C# then you may have used these operators before and you can most likely tune out now and go and catch the latest episode of .

If you’re still here, let’s look at how operator in question differs from the above code. Well, for a start, you’d write it like this instead:

#typescript #javascript #web-development #programming

Double Question Marks TypeScript 3.7 - Nullish Coalescing
2.00 GEEK