3 ms·
The underlying problem why this isn't clear to pure JS developers is that even the native APIs do this differently, but for various reasons. For example, take
by cookiengineer 6y ago
The underlying problem why this isn't clear to pure JS developers is that even the native APIs do this differently, but for various reasons.
For example, take Array.prototype.find(). Would be nice to have null here as a default return value. But what about Arrays containing null as a value? What about the case of null || false? What about the case of false || null?
There were a lot of design discussions to come up with those APIs...but I agree with you that technically, undefined should not exist. I'd rather have a syntax error being thrown than having to deal with undefined.
As undefined is specified as a hackaround as a global property, ... most of the implications are just a workaround, too.