Possible Duplicate:
Using bitwise OR 0 to floor a number
Performs a bitwise OR on two expressions,eg:
console.log(12.22|0) // output --->12
where does the decimal go?
it’s the same as parseInt function
parseInt(12.22) // output --->12
how does it work?
parseIntis useful in cases where one is parsing strings such as “12px”.For example:
However, this doesn’t make any sense with bit-wise OR:
Performing a bit-wise OR is more like applying
Math.floor()to a number — bitwise operations work on 32-bit integers in Javascript.