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

3===3 && doSomething() #1

Closed
JoaoFOliveira opened this issue Nov 26, 2014 · 2 comments
Closed

3===3 && doSomething() #1

JoaoFOliveira opened this issue Nov 26, 2014 · 2 comments

Comments

@JoaoFOliveira
Copy link

Was looking through index.js and found

   (oldValue !== newValue) && (changes.push(['analogChange', newValue])); 

and

   (oldValue !== newValue) && (changes.push([k + (newValue ? 'Press' : 'Release')]));

and so forth.

Noticed it was not a statement nor a function call, but something like (i.e. true/false && execute())

Some JS linting notices this and throws some warnings/errors like

   Expected an assignment or function call and instead saw an expression.

and after some digging found this to be more of an readability issue, as tools like uglify.js turn "if(this) {that()}" into "this && that()"

Brief discussion about this in

airbnb/javascript#52

@JoaoFOliveira
Copy link
Author

Also,

   !!(secBtns & 0x10),

what is "&" supposed to do here? Is it missing a twin?

@marcooliveira
Copy link
Owner

I did that on purpose to make the code smaller. Don't like seeing a lot of lines when I don't need it. As this was sort of a hack, I'm not even sure if I changed the .jshintrc to suppress that kind of warning.

As for the "missing twin" &, it's a bitwise AND.

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