function calls: direct vs apply vs call vs bind (v97)

Revision 97 of this benchmark created on


Setup

var f = function(foo, a, b, c){
    return [foo, a, b, c];
  };
  
  var f2 = function(a, b, c) {
    return [this, a, b, c];
  };
  
  var foo = {};
  
  var a = 1, b = 2, c = 3, abc = [1, 2, 3];
  
  var bound = f2.bind(foo);

Test runner

Ready to run.

Testing in
TestOps/sec
direct
f(foo, a, b, c);
ready
apply
f2.apply(foo, abc);
ready
call
f2.call(foo, a, b, c);
ready
bind
bound();
ready
apply2
f2.apply(foo, [a, b, c])
ready

Revisions

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