Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
tagName vs instanceof
(version: 0)
Comparing performance of:
instanceof vs tagName vs nodeName vs localName vs __proto__
Created:
6 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var xs = []; var n = 0; for (let i = 0; i < 1000; ++i) { xs[i] = (Math.random() > .5) ? document.createElement(`div`) : document.createElement(`span`); };
Tests:
instanceof
n += ((xs[(Math.random() * 1000)|0]) instanceof HTMLDivElement)|0;
tagName
n += (xs[(Math.random() * 1000)|0].tagName === `DIV`)|0;
nodeName
n += (xs[(Math.random() * 1000)|0].nodeName === `DIV`)|0;
localName
n += (xs[(Math.random() * 1000)|0].localName === `div`)|0;
__proto__
n += ((xs[(Math.random() * 1000)|0]).__proto__ === HTMLDivElement.prototype)|0;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
instanceof
tagName
nodeName
localName
__proto__
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Browser/OS:
Chrome 141 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
instanceof
6272783.5 Ops/sec
tagName
5864679.5 Ops/sec
nodeName
5822863.5 Ops/sec
localName
6131639.0 Ops/sec
__proto__
7781024.5 Ops/sec
Related benchmarks:
nodeType vs instanceof
nodeType vs instanceof 2
nodeType vs instanceof 3
tagName.toLowerCase() vs instanceof
Comments
Confirm delete:
Do you really want to delete benchmark?