Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Node instanceof vs property checks
(version: 1)
Comparing performance of:
instanceof vs property checks
Created:
10 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here--> <div id="root"></div>
Script Preparation code:
(function () { let root = document.getElementById('root'); let nodes = Array(10_000); for (let i = 0; i < 10_000; ++i) { nodes[i] = document.createElement('div'); } root.append(...nodes); })()
Tests:
instanceof
let root = document.getElementById('root'); for (let i = 0; i < root.children.length; ++i) { let child = root.children[i]; console.log(child instanceof HTMLDivElement); }
property checks
let root = document.getElementById('root'); for (let i = 0; i < root.children.length; ++i) { let child = root.children[i]; console.log(child.nodeType === Node.ELEMENT_NODE && child.tagName === 'div'); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
instanceof
property checks
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser/OS:
Chrome 138 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
instanceof
70.3 Ops/sec
property checks
67.4 Ops/sec
Related benchmarks:
Remove children
Example
testtesttesttest
For, While
nodeName
Spread vs Array.from on NodeList
Spread vs Array.from on querySelectorAll
Test (innerHTML, replaceChildren, remove, removeChild)
Test (while or forEach)
Comments
Confirm delete:
Do you really want to delete benchmark?