-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some values (like undefined) should have a reserved keywords (like null) #25
Comments
It's pretty much become taboo to use the identifier But I don't think a keyword would have been the ideal solution. It should have been omitted entirely. What other language has two absence representations? |
Agreed—to date, the best (though, IMO, not fully correct) distinction I've seen between |
Fair enough. I created issue #26 and I'm repurposing this issue from: |
@DavidBruant: Are you forgetting about |
I totally am. Making the title more general and keeping the list up-to-date in the description. Thanks! |
Has anobody ever been in a situation were undefined or NaN were redefined ? I think people deserve what they're gonna get if they do that. I don't usually check with typeof, I just don't see the point in doing that. |
I agree with you but that's not the point here. The idea of ECMAScript Regrets is to list all the things the language got wrong and can't be fixed because some content on the web may relies on the particular behavior. The idea is to educate JS devs and hopefully help compile-to-JS language designers. Per ES5, it is not possible to redefine them, but it's possible to use them as identifiers (variable names, function arguments...). There is no good reason to do that, so there is no reason for the language to allow that (hence being a "regret") |
Fair enough; I agree :). |
Some names (like
undefined
andNaN
) can be used as identifiers making it hard to use them 100% reliably as values (which is what people expect naturally). This leads people to write things liketypeof x === "undefined"
while they could just be writingx === undefined
, or usevoid 0
etc.List of things that shouldn't be allowed as identifiers:
undefined
NaN
Infinity
The text was updated successfully, but these errors were encountered: