Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
nodeType vs instanceof 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
nodeType
7223478.0 Ops/sec
instanceof
6048250.0 Ops/sec
nodeType literal
7637739.0 Ops/sec
Script Preparation code:
var xs = []; var n = 0; for (let i = 0; i < 1000; ++i) { xs[i] = (Math.random() > .5) ? document.createElement(`a`) : document.createTextNode(``); };
Tests:
nodeType
n += (xs[(Math.random() * 1000)|0].nodeType === Node.ELEMENT_NODE)|0;
instanceof
n += ((xs[(Math.random() * 1000)|0]) instanceof HTMLElement)|0;
nodeType literal
n += (xs[(Math.random() * 1000)|0].hasOwnProperty('nodeType'))|0;