Re:Intent to stop using 'null' in my JS code
by ZephyrBlu on Sunday November 01, 2020 @01:05PM
(#24961244)
That's the point though. I can easily do a null check to handle whether or not to process/use the value.
For instance, if I'm fetching some data I usually want to initialize the data variable as null for a couple of reasons.
1) null is not truthy, empty arrays and objects are
2) It shows that the variable is supposed to be filled, unlike undefined
It would be better to just error out and not allow the uninitialized usage at all, but unfortunately that's not possible in Javascript.