Function or No Function

by jacobwsmith

JavaScript

console.clear();

// No Function Test
{
  const t0 = performance.now();
  const scripts = document.getElementsByTagName('script');
  const numberOfScripts = scripts.length;
  console.log('numberOfScripts: ', numberOfScripts);
  const t1 = performance.now();
  console.log("No Function Test took " + (t1 - t0) + " milliseconds.");
}

// Function Test
/* {
  const t0 = performance.now();
  const doSomething = function() {
    const scripts = document.getElementsByTagName('script');
    return scripts.length;
  }
  const numberOfScripts = doSomething();
  console.log('numberOfScripts: ', numberOfScripts)
  const t1 = performance.now();
  console.log("Function Test took " + (t1 - t0) + " milliseconds.");
} */