Function versus Function.call versus Function.apply (v22)

Revision 22 of this benchmark created on


Setup

var o = {
        f: function f(a, b, c) {
            return [a, b, c];
        },
        ff: new Function('a', 'b', 'c', 'return [a, b, c];')
    }, d = "string", e = 123, f = ['a', 'r', 'r', 'a', 'y'], z = [d, e, f];

Test runner

Ready to run.

Testing in
TestOps/sec
Direct
o.f(d, e, f)
ready
Call
o.f.call(o, d, e, f)
ready
Apply
o.f.apply(o, [d, e, f])
ready
Apply predefined array
o.f.apply(o, z)
ready
Call with spread
o.f.call(o, ...z)
ready
Direct with Spread
o.f(...z)
ready
Call with null
o.f.call(null, d, e, f)
ready
Direct with Spread II
o.f(...[d, e, f])
ready
New Function
o.ff(d, e, f)
ready

Revisions

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