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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Browser:
Safari 18
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
nodeType
32008834.0 Ops/sec
instanceof
34410944.0 Ops/sec
nodeType literal
83301696.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;