or vs ref?:

JavaScript performance comparison

Test case created by Nami

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var fn = function () {
      return 5;
    };
    var fn2 = function () {
      return 7;
    };
    var noop = function (it) {
      it+2;
    };
};
</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
or
noop(fn() || fn2());
pending…
ref?:
var ref;
noop((ref = fn()) ? ref : fn2());
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment