0 ) statement gives an integer in javascript
This question already has an answer here:
The |
operator performs bitwise logical OR
. It requires its parameters to be integers, so it will convert a string to an integer. So
( number | 0 )
is equivalent to:
( parseInt(number, 10) | 0 )
Any number or'ed with 0
will return that same number, so that makes it equivalen to:
parseInt(number, 10)
Well, the single pipe between the number and 0 is bitwise operator that treat their operands as a sequence of 32 bits (zeroes and ones). https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#.7c_%28Bitwise_OR%29
链接地址: http://www.djcxy.com/p/77442.html上一篇: 不能理解使用