Detect Native DOM Element via noteType vs. instanceof
JavaScript performance comparison
Info
Preparation code
<script>
Benchmark.prototype.setup = function() {
var isElementInstance = function(ukn) {
return ukn instanceof Element;
};
var isElementNode = function(ukn) {
return 1 === ukn.nodeType;
};
var body = document.body;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
instanceof |
|
pending… |
nodeType |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments