Method Missing (v2)

Revision 2 of this benchmark created 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
eval
eval("foo.bar()")
ready
Function constructor
Function("foo && foo.bar()")
ready
try/catch
try{foo.bar()}
catch(e){Function()}
ready
void
void(baz=eval("foo.bar()"))
ready

Revisions

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