CIS 119 Chapter 8

Objectives

  • Use the equality and identity operators.
  • Use the relational operators
  • Use the logical operators
  • Use selection statements (if, switch)
  • Use the conditional operator
  • Use while and do/while loops
  • Use for loops
  • Use the break and continue statements

Online notes for the week

Chapter 8 outline

  • Relational operators
    • ==: equality (type coercion performed)
    • !=: inequality (type coercion performed)
    • ===: identity (type coercion not performed)
    • !==: non-identity? (type coercion not performed)
    • <: less than
    • <=: less than or equal to
    • >: greater than
    • >=: greater than or equal to
    • Operands converted to numbers except when both are strings
    • NaN is not equal to NaN
    • null is equal to undefined
    • false is equal to 0
    • true is equal to 1
    • the empty string is converted to 0 if numeric conversion is done
  • Logical operators
    • !: not
    • &&: and
    • ||: or
  • Operator precedence
    • !
    • <, <=, >, >=
    • ==, !=, ===, !==
    • &&
    • ||
  • Selection
    • if
    • if/else
    • switch
    • break
    • conditional
  • Repetition
    • while
    • do/while
    • for
    • for-in (iterates over enumerable properties)
    • for-of (iterates over itreable properties)
    • .forEach (applies function to each element in an Array object
    • break [label]
    • continue [label]