Nullish Coalescing vs Logical OR?!

?? and || are DIFFERENT! Nullish coalescing only checks null/undefined. Logical OR checks ALL falsy values. 0 and '' behave differently! This matters!

#javascript #javascripttricks #nullishcoalescing #logicalor #falsyvalues #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #operatordifferences #advancedjavascript

https://www.youtube.com/watch?v=pd6wpNTvbiM

Nullish Coalescing vs Logical OR?! #javascriptwtf

YouTube

Nullish Coalescing vs Walrus Operator: Modern Operator Face-Off

JavaScript ?? operator vs Python := walrus operator. Which language's modern operator is more useful? This comparison is INSANE!

#javascript #python #javascriptvspython #nullishcoalescing #walrusoperator #modernoperators #programmingcomparison #codecomparison #javascripttricks #pythontricks #syntaxcomparison #viralcoding #codingshorts #es2020 #python3.8

https://www.youtube.com/watch?v=9ZiNZGWBdw8

Nullish Coalescing vs Walrus Operator: Modern Operator Face-Off #viralcoding

YouTube
Invalid values and the nullish coalescing operator in JavaScript

After working as a JS/TS developer for quite some years I've grown quite used to seeing || "" or ?? "" strewn around codebases as a quick fix to "remove" nullability, usually due to some value which you assume is set, but can't "prove" type-wise. I think this is a code smell, and I generally think it's not the right solution. In this post I try to explain why I don't think so, and provide some patterns that could help combat the downsides introduced by this pattern.

Fredrik's Homepage