简体   繁体   中英

Unexpected use of '>>>' in cross-browser split

I put cross-browser split into my code and run it through jsHint and got Unexpected use of '>>>' in lines:

limit = limit === undef ?
    -1 >>> 0 : // Math.pow(2, 32) - 1
    limit >>> 0; // ToUint32(limit)

the same is when I put it in one line and also put expressions into parentheses

is this error? How can I fix it?

You can disable the error (well, they really should call it a warning) by turning off the "When bitwise operators are used" option (the top option listed here — oddly, the documentation doesn't mention all of the bitwise operators it relates to); if you do, the code above doesn't produce an error.

Here's the rationale for warning about the use of bitwise operators from the original JSLint tool (JSHint is a friendlier version of JSLint with more options to turn off "errors" that are purely style):

Bitwise Operators

JavaScript does not have an integer type, but it does have bitwise operators. The bitwise operators convert their operands from floating point to integers and back, so they are not as efficient as in C or other languages. They are rarely useful in browser applications. The similarity to the logical operators can mask some programming errors. The bitwise option allows the use of these operators: << >> >>> ~ & | .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM