Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
z-indexes collection and coercion
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0
Browser:
Firefox 123
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Number + isNaN
3406.1 Ops/sec
Number.parseInt + Number.isInteger
165787.1 Ops/sec
Number.parseInt + simple condition
159179.7 Ops/sec
HTML Preparation code:
<div class="container"></div>
Script Preparation code:
const container = document.querySelector('.container'); const cloneTarget = document.createElement('div'); const listToInsert = document.createElement('div'); listToInsert.id = 'clone-list'; for (let i = 0; i < 100; i++) { const clone = cloneTarget.cloneNode(true); clone.id = "clone_" + i; clone.textContent = 'I am clone ' + i; listToInsert.append(clone); } container.append(listToInsert); var elements = document.querySelectorAll('#clone-list *');
Tests:
Number + isNaN
for (let el of elements) { const zIndex = Number(el.style.zIndex); if (!isNaN(zIndex)) { console.log(true); } }
Number.parseInt + Number.isInteger
for (let el of elements) { const zIndex = Number.parseInt(el.style.zIndex, 10); if (Number.isInteger(zIndex)) { console.log(true); } }
Number.parseInt + simple condition
for (let el of elements) { const zIndex = Number.parseInt(el.style.zIndex, 10); if (zIndex || zIndex === 0) { console.log(true); } }