3 ms·
Always use undefined, and never null
- thatxliner 1y agoThere's also this article for further discussion: https://www.harness.io/blog/bias-against-null-javascript https://www.harness.io/blog/bias-against-null-javascript
- deleted 1y ago[deleted]
- NoahZuniga 1y agoI find the semantic distinction between null and undefined helpful. If something is undefined, my code hasn't set it. If it's null, the value has been set, but there is no data. I've never experienced this, but if there is ever a point in my logic where undefined and null are both valid values, they probably require different handling, so just always using undefined is not a good idea.