Object is undefined
JavaScript performance comparison
Info
There are a few different ways to check if an object is undefined. Which is the best for speed and also size.
Preparation code
<script>
var a;
var b = 42;
var undefinedVar;
var undefinedStringCached = "undefined";
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
typeof "undefined" |
|
pending… |
typeof "undefined" cached |
|
pending… |
undefined |
|
pending… |
void(0) |
|
pending… |
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 by Corban Brook
0 comments