Home » JavaScript » JavaScript Statements » Question

JavaScript Statements

  1. Consider the following statements
    switch(expression)
    {
    statements
    }

    In the above switch syntax, the expression is compared with the case labels using which of the following operator(s)?
    1. ===
    2. equal
    3. equals
    4. ==
    5. None of these
Correct Option: A

A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. When a switch executes, it computes the value of expression and then looks for a case label whose expression evaluates to the same value (where sameness is determined by the === operator).



Your comments will be displayed only after manual approval.