Assignment Operators

Arithmetic Operators

Bitwise Operators

These convert operand(s) to 32 bits and then perform work on them. In the examples provided, the binary is shown instead of the decimal, for the sake of visual clarity.

Logical Operators

These are typically used with Boolean operands to return Boolean values but for JS 1.1, some of these operators can also be used to return one of the operands, thus effectively "overloading" these operands to work as yet another if ... else shorthand. This makes the order of operands relevant!

Comparison Operators

  • ==. Equal. True if operand values are equal. A data type conversion is automatically performed if needed.
    //The following are true because of auto conversion.
    5 == "5"
    null == undefined;
    
    a2 = new A;
    a1 = new A;
    a1 == a2; //false because object must have the same address space.
    
    NaN == NaN; //false because NaN is not equal to anything, including NaN!
    
  • !=. Not equal.
    NaN != NaN; //true because NaN is not equal to anything, including NaN!
    
  • ===. Strict equal. True if operand values and data types are equal.
    5 === "5" //false
    null === undefined; //false
    
    a2 = new A;
    a1 = new A;
    a1 === a2; //false because object must have the same address space.
    
    NaN == NaN; //false because NaN is not equal to anything, including NaN!
    
  • !==. Strict not equal.
  • >.
  • <.
  • >=.
  • <=.
  • String Operators

    Other Operators

    Operator Precedence

    From low to high:

    Page Modified: (Hand noted: 2008-04-30 21:12:20Z) (Auto noted: 2010-12-24 22:45:53Z)