DEV Community

Discussion on: Replace null with ES6 Symbols

Collapse
robinpokorny profile image
Robin Pokorny Author

Yeah, I see that point. However, with so many falsy values in JS, I would not use the same for null or undefined either.

const value: string | null | undefined = 

if (value) { /* a non-empty string – intention or oversight? */}

if (value == null) { /* a string */ }
Enter fullscreen mode Exit fullscreen mode

Maybe NaN is a better choice? :D

Collapse
0916dhkim profile image
Donghyeon Kim

Actually, I was caught off guard by empty strings a few times before. You have a good point.