|
|
|
|
|
by ngruhn
8 days ago
|
|
You can't get rid of undefined. You can't ban null either. They're both used in the core language all over the place: undefined camp: - out of bounds array index access [1,2,3][42] - non existent object key access {}.foo - array.find(...) no result - ... null camp: - document.querySelector(...) no result - regex.match(...) no result - ... |
|
Could the language have done without both null and undefined? Definitely. But it's here and here to stay.
Though, it's not the only language with two nulls. Julia has nothing and missing, though their semantics are more well defined and with different behaviors than in JavaScript.