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:
one year ago
by:
Guest
Go 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:
one month ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
Browser/OS:
Chrome 148 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
instanceof
48/s
property checks
46/s
View exact numbers
Test name
Executions per second
✓
instanceof
48 Ops/sec
property checks
46 Ops/sec
Related benchmarks
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?