-
Notifications
You must be signed in to change notification settings - Fork 1.7k
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Number.NaN and reserved word #286
Comments
Yes, it's a bug. But can you give me an example where you use var x = Number.NaN;
if (isNaN(x)) {
x = 2;
} Reserved keywords. abstract enum int short
boolean export interface static
byte extends long super
char final native synchronized
class float package throws
const goto private transient
debugger implements protected volatile
double import public In ES5 the list ist somewhat shorter class enum extends super
const export import when in implements let private public yield
interface package protected static I think, jshint should warn if I use one of them, too - even if they are defined in ES3 or if the parser is not in |
Yes, I use Number.NaN for an assignment (if any numeric property can not be destiguished I assign Number.NaN - I could also just use NaN... BUT in older Browser it may be overwritten by a different script) and you can not use it for testing because (NaN === NaN) === false only value in JS that is not equal to it self. |
The "boolean"-issue is still open... |
NaN is not a reserved word according to the ES5 spec and treating it like one prohibits the use of (equally valid) Number.NaN. Relevant: * List of ES5 reserved words: http://es5.github.com/#x7.6.1 * Closes jshintGH-286
If I use Number.NaN (which is perfectly valid) I get
Expected an identifier and instead saw 'NaN' (a reserved word).
First: NaN is NOT a reserved word - it is a global Variable that should not be overwritten (and JSHint should warn you if you do it).
Second: Number.NaN is part of the ES-spec (in 3 and 5)
PS: in ES3 are some FutureReservedWords (like "boolean") which are not recognised in JSHint. If I write
var obj = {boolean: true};
I get no warning form JSHint although it's invalid ES3 (not ES5), because in ES3 an identifier cannot be a reserved word.
In fact I know no Browser who claims about this (I only checked "boolean") - but just for consistency.
The text was updated successfully, but these errors were encountered: