Why those Javascript snippets perform the same?
JavaScript performance comparison
Info
http://stackoverflow.com/questions/14407099/why-those-javascript-snippets-perform-the-same#14407099
Preparation code
<script>
Benchmark.prototype.setup = function() {
obj = [1,2,3,4,5];
function iter(){
for (var key in obj){
key=key+key;
};
};
function test1() {
iter(obj);
};
function test2(){
(function iter(obj){
for (var key in obj){
key=key+key;
};
})(obj);
};
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
function |
|
pending… |
anonymous function |
|
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
0 comments