JSFiddle - React, Tailwind, and code Playground

by Zhelyakea

HTML

<body id="bodyId">
  <div>
    <div class="divClass">
      <div>
        <button id="buttonId">
        </button>
      </div>
    </div>
  </div>
  <div>
    <div>
   </div>
  </div>
</body>

JavaScript

'use strict'
function querySelectorFoo() {
  document.querySelector('#buttonId');
}
function getElementByIdFoo() {
  document.getElementById('buttonId')
}

var numbers = [];
for (var i=0; i < 100; i++) {
  let t0 = performance.now();
  let result = getElementByIdFoo()
  let t1 = performance.now();
  var t = t1 - t0;
  console.log(t0);
  console.log(t1);
  numbers.push(t1 - t0);
}

function median(sequence) {
  sequence.sort();  // note that direction doesn't matter
  return sequence[Math.ceil(sequence.length / 2)];
}

console.log('Median time', median(numbers).toFixed(4), 'milliseconds');
console.log(numbers);