Testing for existence of a property
JavaScript performance comparison
Info
Does bypassing the prototype chain make a difference?
Preparation code
<script>
Benchmark.prototype.setup = function() {
if (typeof Object.create !== 'function') {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}
var obj1 = {},
obj2 = Object.create(obj1),
obj3 = Object.create(obj2),
obj4 = Object.create(obj3),
obj5 = Object.create(obj4),
prop;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Dot syntax |
|
pending… |
Square bracket syntax |
|
pending… |
hasOwnProperty |
|
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 Kevin Ennis
- Revision 2: published
0 comments