Pages

Sunday, November 13, 2016

Logical and Bitwise Operators


a: ← Operand (number, true or false)
b: ← Operand (number, true or false)

← Operand examples


Exercise

  • For each example pair of operands, study the result of "passing" the operands to the corresponding logical or bitwise operators.
  • Try other pairs of operands.
  • Attempt to empirically determine the rules associated with each logical and bitwise operator.
  • For each operator, after you have formed a hypothesis about how the operator works, compare your hypothesis with documentation (print or online) for that operator. For example:
  • Formulate a question about something you don't understand related to a logical or bitwise operator, and find an answer to your question. How much confidence do you have in the answer? Why?
  • Optional: Compare the logical and bitwise operators for JavaScript with those for Java.
    • Does Java have the same logical and bitwise operators that JavaScript does?
    • Are there any differences between the way the JavaScript logical and bitwise operators work compared to the corresponding Java ones?