Loop scope
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var data = (function() {
var r = {};
for (var i=0; i < 1000; i++) {
r[i] = {
'number': i,
'date': new Date().valueOf()
}
};
return r;
})();
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
outside, same scope |
|
pending… |
inside |
|
pending… |
outside, anon function |
|
pending… |
outside, declared function |
|
pending… |
outside, named function |
|
pending… |
outside, anon function, twice |
|
pending… |
outside, declared function, twice |
|
pending… |
outside, named function, twice |
|
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
- Revision 2: published
- Revision 3: published
0 comments