exiting nested switch within for...in

JavaScript performance comparison

Test case created by brad

Info

test various escape methods to leave a switch statement nested within a for...in.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var o = {a:'a',b:'b',c:'c',d:'d',e:'e',f:'f'};
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Variable flag
var keepGoing = true;
for (var k in o){
    switch (k){
        case 'd':
            keepGoing = false;
            break;
        default:
            break;
    }
    if (!keepGoing) break;
}
pending…
anonymous function return
(function(){
    for (var k in o){
        switch (k){
            case 'd':
                return;
            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