apply vs call vs invoke (v13)

Revision 13 of this benchmark created by Michael Benin on


Setup

function fn(a,b,c,d) {return a+b+c+d;}
    var obj = {};

Test runner

Ready to run.

Testing in
TestOps/sec
apply
fn.apply(obj, ['a','b','c','d']);
ready
call
fn.call(obj, 'a', 'b', 'c', 'd');
ready
invoke
obj.fn = fn;
obj.fn('a','b','c','d');
delete obj.fn;
ready
apply (undef)
fn.apply(undefined, ['a','b','c','d']);
ready
call (undef)
fn.call(undefined, 'a', 'b', 'c', 'd');
ready
invoke (undef)
fn('a','b','c','d');
 
ready
self invoke
(function(a,b,c,d) {return a+b+c+d;}());
var obj = {};
ready

Revisions

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