function calls: direct vs apply vs call (v83)

Revision 83 of this benchmark created by Roland Pihlakas on


Preparation HTML

<script>
var a = [1, 2, 3];
var b = [];
var obj = {
    foo: function () {
        var len = arguments.length;
        return this.bar;
    },
    bar: 'baz'
};
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
direct
obj.foo(1, 2, 3);
ready
apply
obj.foo.apply(obj, a);
ready
call
obj.foo.call(obj, 1, 2, 3);
ready
apply-like call
obj.foo.call(obj, a[0], a[1], a[2]);
ready
apply-like call, unknown arguments
obj.foo.call(obj, b[0], b[1], b[2]);
ready

Revisions

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