re: 😲🤯The most outstanding new feature in Javascript you need to know about: Optional Chaining VIEW POST

re: Why const personFirstName = person?.details?.name?.firstName ?? 'stranger' Rather than const personFirstName = person?.details?.name?.first...

Probably that ?? only cares about undefined properties, not null or zero or empty string etc.


It's called nullish for a reason. Because for some reason, JS thought two nulls would be a good idea.

May be a long argument but it's not two nulls, it's a null (defined) and an undefined. They have usefully different meanings and usages. Saying it's two nulls is a bit like saying that zero and null are the same because they both mean "nothing".

I would have to agree with you, however in the wild most code I've seen misinterprets this and there is mixed usage of both all over the place..

And everybody is true here :)

I try to use undefined as much as I can instead of null.

But some frameworks want you to use null.

code of conduct - report abuse