Property detection
JavaScript performance comparison
Info
These test if a property exists in an object. The boolean syntax is often used, but can lead to wrong results (a property with a value of false wouldn't be detected, for example).
Preparation code
<script>
var obj = {
a: 1
};
var el = document.createElement('div');
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
in operator |
|
pending… |
boolean value |
|
pending… |
hasOwnProperty |
|
pending… |
boolean value 2 |
|
pending… |
in operator (element) |
|
pending… |
boolean value (element) |
|
pending… |
hasOwnProperty (element) |
|
pending… |
boolean value 2 (element) |
|
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 Thomas Fuchs
- Revision 2: published
- Revision 3: published by Thomas Fuchs
- Revision 4: published
- Revision 5: published by Tom
- Revision 12: published by Mourner
- Revision 13: published
0 comments