How does the switch statement compare the expression with the case values (strict or loose comparison)?

  • Strict comparison (===)
  • Loose comparison (==)
  • It depends on the JavaScript engine being used.
  • It uses a custom comparison method.
The switch statement in JavaScript uses loose comparison (==) to compare the expression with the case values. This means that it does not consider the data type. For strict comparison (===), you can use if-else statements within each case block.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *