Skip to content
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

Unexpected space error #6

Closed
Mottie opened this issue Dec 2, 2010 · 1 comment
Closed

Unexpected space error #6

Mottie opened this issue Dec 2, 2010 · 1 comment

Comments

@Mottie
Copy link

Mottie commented Dec 2, 2010

I use JSLint to check my jQuery scripts and if I check code like this using "The Good Parts", it only tells me jQuery isn't defined - which is fine:

jQuery('.selector')
  .removeAttr('style')
  .show();

Now if I define an action and use it this way:

var showOrHide = 'show';
jQuery('.selector')
  .removeAttr('style')
  [showOrHide]();

I get an additional error stating Unexpected space before '['.

The only way to get rid of this error is to format the script like this, which I think make it more unreadable:

var showOrHide = 'show';
jQuery('.selector')
  .removeAttr('style')[showOrHide]();

So my question is would it be possible to make the second example not produce an error?

Thanks :)

@douglascrockford
Copy link
Collaborator

You should take JSLint's advice.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants