switch vs. if...else if...else

Posted by John Hartsock on Stack Overflow See other posts from Stack Overflow or by John Hartsock
Published on 2010-05-27T16:30:55Z Indexed on 2010/05/27 16:41 UTC
Read the original article Hit count: 103

Guys I have a couple of questions:

  1. Is there a preformance difference in Javascript between a switch statement and an if...else if....else?
  2. If so why?
  3. Is the behavior of switch and if...else if...else different across browsers? (FireFox, IE, Chrome, Opera, Safari)

The reason for asking this question is it seems that I get better preformance on a switch statement with approx 100 cases in Firefox. But in IE it get better preformance with 100 if...else if...else.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about cross-browser