Possible Duplicate:
what's the difference between ( | ) and ( || ) in javascript?
I’ve seen this in a couple examples here but I never fully understood what it’s supposed to do. Can anyone give me a simple example please?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Javascript, the
|operator is a bitwise operators (in contrast to the||operator which is a logical operator).It convert each operand to a 32-bit number, and performs a bitwise or between them.
Example of expressions and their results:
Reference: http://developer.mozilla.org/en/JavaScript/Reference/operators/bitwise_operators