Why does JSHint argue against bitwise operators? How should I express this code?

Solution 1:

Put

/*jshint bitwise: false*/

in the top of your file

A list of available options: http://jshint.com/docs/options/

Solution 2:

According to JSHint docs, it is because

"Bitwise operators are very rare in JavaScript programs"

As others have mentioned, you can disable the bitwise JSHint option to squelch the warnings.

Solution 3:

You've jammed so much code into one line (why??) that you can't tell what jshint is pointing out to you. I've reformatted the code, and I see this:

var r = Math.random() * 16 | 0, 

What is the | 0 doing there? It's a needless no-op. UPDATE: seems to be a way to int-ify a float.

Jshint seems to not like other things, but at least get rid of this. And spread your code out so that you (and others) can read it.