Skip to content

regexES51ReservedWords added to js test #15

Open
wants to merge 1 commit into from

2 participants

@zsitro
zsitro commented Sep 26, 2012

I can complete the list with over 20-50 reserved words (missing from the list) if this pull request passes...

Greets,
Zsitro

@mathiasbynens
Owner

While it’s a good idea not to use these identifiers as global variable names in browser environments, they’re not prohibited by the spec (which is what this tool checks for). They’re not listed in http://ecma-international.org/ecma-262/5.1/#sec-7.6.1, so I don’t think they should be added here.

That said, I’d be interested in seeing your full list.

@zsitro
zsitro commented Sep 26, 2012

If you use "self" for example in IE to declare a variable, your script will fail with "Not Implemented" error. That's a very strong reason why it's NOT a proper variable name.

http://zsitro.com/self-is-a-protected-namespace-in-ie-avoid-using-it-as-a-local-variable-name/

I suggest to add a new regex group with "avoid" status.
I can try to implement it...

@mathiasbynens
Owner

Interesting. Which version(s) of IE does this apply to? Is there an online test case to reproduce the issue? Are you sure this is not simply because you forgot to use var before self?

@zsitro
zsitro commented Sep 26, 2012

Here you go: http://jsbin.com/irikus/5 The message will be alerted in IE.

@mathiasbynens
Owner

Which IE version(s)? Are you sure this is not simply because you forgot to use var before self?

@zsitro
zsitro commented Sep 26, 2012

All IEs! Take a look at this example: http://jsbin.com/irikus/7/ Here I do not use var before variable name, because $(document).ready(function( will expose them to the global window scope. So the expected behavior would be:

first button click => alerts 1
second button click => alerts 2

And that's what happens in every browser except in ie. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.