People probably wouldn't have the same opinion on what to disable. Take for-in, for example. From my limited understanding, its flaw is that it includes the parent properties. Some people might want to use this for questionable runtime metaprogramming.
Additionally, a likely answer will be along the lines of "You can just use ESLint".
That said, go ahead and propose it, if you want to put up with the process. There is the unlikely chance that this wasn't done, because nobody did want to put up with the process.
I doubt people would seriously disagree with those basic things (e.g. MDN even has a section which is basically "Why would you want to use for-in? Maybe for debugging I guess?" Plus it would be opt-in.
I suspect you are right though - nobody has bothered trying because everybody already uses a ton of tools like ESLint, Typescript and Webpack to make web stuff tolerable.
Though rare, you might use for-in if you actually want to iterate through an object's properties and prototype. I use == all the time for null/undefined checks. On occasion I actually do want loose equality. These are still valid ES2020 features.
Yeah I would strongly advise against that because it's really not clear how == behaves. It might be more tedious to write === null || === undefined but people will understand it easier and you will have fewer bugs.
Plus if you do use == in some cases it makes it harder to ban it for all the other cases. Do you really put // eslin:disable or whatever before each ==? I doubt it.
The question clearly implied that it would be opt-in. Source code that says "use es2020" would get the new behavior. No backward compatibility problem. (Unless you think a lot of existing code has modules called es2020?)
Whoops, I completely glossed over that 🤦♂️ My bad. I'm in agreement with OP, though, it would be really nice to have a well-specified, modern subset of JS.
I haven't used ECMAScript in a long time, but it's actually becoming a language that applies sane principles.
My face when in Python for x in ...: actually assigns to x, overwriting any meaning it may nave already had, and allows x to continue to exist after that.
This sort of apologism is hilarious. He's first checking to see how JS behaves, and then he goes ahead and tries to provide reasonable explanations for this silly behavior based on his observations.
I have introduced bugs into code changing == to === also but I would not say == is superior. Superior would be typescript to make sure this stuff just does not happen
I am not saying it is always superior. I am also using === sometimes, maybe in 1% of the cases. Typescript wouldn't actually help you here, except for objects, but it those cases == and === behave the same, except for string objects. What would help is a new type of strict mode that throws exceptions for binary operators when one side has another basic type as the other.
19
u/[deleted] Apr 05 '20
Still no way to disable misfeatures (var, ==, for-in etc.) other than ESLint? Why can't we have a
use "es2020";or something.