Function versus Function.call versus Function.apply
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var o = {
f: function f(a, b, c) {
return [a, b, c];
}
}, d = "string", e = 123, f = ['a', 'r', 'r', 'a', 'y']; allArgs = [d, e, f];
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Direct |
|
pending… |
Call |
|
pending… |
Apply |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Michael A. Smith
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 6: published
- Revision 7: published
- Revision 8: published
- Revision 9: published
- Revision 10: published by Apply, Call
- Revision 11: published by Emil
- Revision 12: published
- Revision 13: published
0 comments