undefined vs local undefined var
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
function test1(stuff) {
if (stuff === undefined) {
stuff += stuff; // never reached
}
}
function test2(stuff, u) {
if (stuff === u) {
stuff += stuff; // never reached
}
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
global undefined |
|
pending… |
local undefined var |
|
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 by @blixt
- Revision 3: published
0 comments