News for hackers. Stuff that matters.
Re:Intent to stop using 'null' in my JS code by chousuke on Sunday November 01, 2020 @06:57AM (#24958871)
null is not a very good default value in most cases though, since the operations you do with values of "real" types will not work on null. Therefore actually using your "default" value is pretty much guaranteed to be a bug, identical to using an uninitialized variable.

It would be better to just error out and not allow the uninitialized usage at all, but unfortunately that's not possible in Javascript.

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