I wonder if there would be a market for a "stricter mode" version of JavaScript that simply does not allow you to use the legacy features that are so quirky.
Eg just disallow for...in to be used at all (but allow for...of)
No iterating over objects except via eg Object.entries
No inheriting objects from other objects (ie no prototypal inheritance)
No var
No anonymous functions (ie only named function declarations or lambda/fat-arrow expressions, to avoid `this` binding gotchas)
Etc
I think the only real big blocker to a thing like this is that it'd need tooling (eg a transpiler that injects error throws at appropriate places), and tooling is another big hairy thing that makes JS less approachable for beginners.
> I wonder if there would be a market for a "stricter mode" version of JavaScript that simply does not allow you to use the legacy features that are so quirky.
It's almost like we could use a better frontend language. Too bad there isn't some magical universal assembly language supported by all major browsers we could use as a launchpad for such a thing ;)
these should be expert mode only features that have to be unlocked as opposed to default. So easy to shoot yourself in the foot. Kinda fun if you've been doing it for a while though.
Eg just disallow for...in to be used at all (but allow for...of)
No iterating over objects except via eg Object.entries
No inheriting objects from other objects (ie no prototypal inheritance)
No var
No anonymous functions (ie only named function declarations or lambda/fat-arrow expressions, to avoid `this` binding gotchas)
Etc
I think the only real big blocker to a thing like this is that it'd need tooling (eg a transpiler that injects error throws at appropriate places), and tooling is another big hairy thing that makes JS less approachable for beginners.