Function Declaration vs. Function Expression
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var element = document.createElement('div'),
ev = (1, eval);
};
Benchmark.prototype.teardown = function() {
element = null;
ev = null;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Function Declaration |
|
pending… |
Function Expression |
|
pending… |
Function Constructor |
|
pending… |
DOM Function Transfer |
|
pending… |
Named Function Expression |
|
pending… |
Eval Call |
|
pending… |
Eval Indirect Call |
|
pending… |
Eval Indirect Call |
|
pending… |
Eval Indirect Call |
|
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 Arthur
- Revision 3: published by Arthur
- Revision 4: published by Arthur
- Revision 5: published
- Revision 6: published
- Revision 7: published and last updated
0 comments