3 ms·
If you're wondering why JavaScript does this, it's because early versions of the language did not have exceptions. So every operation defined at the time has to
by rictic 9y ago
If you're wondering why JavaScript does this, it's because early versions of the language did not have exceptions. So every operation defined at the time has to return some value for every possible input, even when those inputs don't make any sense.
It's likely that the only way we could get rid of this behavior would be through some `use strict`-like opt-in semantics.
TypeScript helps a lot too: https://www.typescriptlang.org/play/#src=0%20%3E%3D%20null%3B%0D%0A0%20%3E%3D%20undefined%3B%0D%0Anull%20%3E%3D%200%3B%0D%0A'10'%20%3E%2010%3B%0D%0A'10'%20%2B%2010%20%3E%2010%3B%0D%0A https://www.typescriptlang.org/play/#src=0%20%3E%3D%20null%3...