News for hackers. Stuff that matters.
Re:Intent to stop using 'null' in my JS code by amw-zero on Saturday October 31, 2020 @11:36PM (#24957031)
Why is this distinction important practically?
Re:Intent to stop using 'null' in my JS code by lmm on Sunday November 01, 2020 @02:11AM (#24957729)
Because they mean very different things. E.g. "no-one owns this land" is very different from "I don't know who owns this land". "You don't need to do anything" is very different from "I don't know what you need to do". "No-one's in that room" is very different from "I don't know who's in that room". Of course the practical difference depends on context, but so does the practical difference between 2 and 3.
Re:Intent to stop using 'null' in my JS code by amw-zero on Sunday November 01, 2020 @08:03AM (#24959195)
That’s not what I asked. I know what the distinction is. I asked why would I ever need that distinction in a program.

In 10 years I’ve never come across a situation where I found that distinction useful.

Re:Intent to stop using 'null' in my JS code by thenanyu on Sunday November 01, 2020 @12:10PM (#24960858)
Agree. I would never attempt to write flow control that had different cases for handling undefined and null. It feels so extremely brittle
Re:Intent to stop using 'null' in my JS code by reificator on Sunday November 01, 2020 @02:53AM (#24957882)
Undefined should mean in most cases that you've made a programming mistake, be that a typo or an invalid assumption about the type of thing you're getting back.

Null should mean in most cases that the data you wanted to access was invalid, but you can expect it to exist there in other circumstances.

Neither are a guarantee in JS, and you can find counterexamples for the counterexamples of the counterexamples, but that's the intention behind each.

Re:Intent to stop using 'null' in my JS code by megous on Sunday November 01, 2020 @09:11AM (#24959586)
In the past it was one of the ways to distinguish between arguments to function that were not passed in by the caller.
Re:Intent to stop using 'null' in my JS code by jolux on Sunday November 01, 2020 @12:25AM (#24957218)
It shouldn’t be but due to the way JavaScript is structured it is.