JSLint reports unexpected use of '&' and '|' — I'd like to clean this

前端 未结 3 2258

I\'m trying to get my Javascript code 100% JSLint clean.

I\'ve got some JS code that I\'ve lifted from elsewhere to create a UUID. That code has the following line:

3条回答
  •  庸人自扰
    2021-01-31 14:34

    The reason "why" is that actual bitwise operations are exceedingly rare in JS, and those operators appearing in JS code almost always are a typo for the boolean versions (&&, ||). That's why JSLint cares. This is a legit use of bitwise ops though. I believe you can silence the warning with the bitwise flag:

    /*jslint bitwise: true */
    

提交回复
热议问题