Method Missing

Benchmark created by Elyon on


Setup

"use strict";
    
    var Foo = function() {
      this.bar = function() { };
    };
    
    var foo = new Foo();

Test runner

Ready to run.

Testing in
TestOps/sec
No check
foo.bar();
ready
typeof ===
if (typeof foo.bar === 'function') {
  foo.bar();
}
ready
|| function
(foo.bar || function(){})();
ready
|| Function
(foo.bar || Function)();
ready
&&
foo.bar && foo.bar();
ready
typeof ==
if (typeof foo.bar == 'function') {
  foo.bar();
}
ready
constructor
foo.bar && foo.bar.constructor === Function && foo.bar();
ready
if
if (foo.bar) {
  foo.bar();
}
ready
&& []
foo['bar'] && foo['bar']();
ready

Revisions

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