If Else and Switch Case

JavaScript performance comparison

Test case created by Dang Van Thanh

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
If Else
var i, test;

if (i === 0) {
  test = '0';
} else if (i === 1) {
  test = '1'
} else if (i === 2) {
  test = '2'
} else if (i === 3) {
  test = '3';
}
pending…
Switch Case
var i, test;

switch (i) {
  case 0:
    test = '0';
    break;
  case 1:
    test = '1';
    break;
  case 2:
    test = '2';
    break;
  case 3:
    test = '3';
    break;
  default:
    break;
}
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment