let TIMES = 1000 * 1000 * 100

console.time("(() => { }) instanceof Function")
for (let i = 0; i < TIMES; i++)
  (() => { }) instanceof Function
console.timeEnd("(() => { }) instanceof Function")

console.time("(async () => { }) instanceof Function")
for (let i = 0; i < TIMES; i++)
  (async () => { }) instanceof Function
console.timeEnd("(async () => { }) instanceof Function")

console.time("(function () { }) instanceof Function")
for (let i = 0; i < TIMES; i++)
  (function () { }) instanceof Function
console.timeEnd("(function () { }) instanceof Function")

console.time("(async function () { }) instanceof Function")
for (let i = 0; i < TIMES; i++)
  (async function () { }) instanceof Function
console.timeEnd("(async function () { }) instanceof Function")

console.time("typeof (() => { }) === 'function'")
for (let i = 0; i < TIMES; i++)
  typeof (() => { }) === 'function'
console.timeEnd("typeof (() => { }) === 'function'")

console.time("typeof (async () => { }) === 'function'")
for (let i = 0; i < TIMES; i++)
  typeof (async () => { }) === 'function'
console.timeEnd("typeof (async () => { }) === 'function'")

console.time("typeof (function () { }) === 'function'")
for (let i = 0; i < TIMES; i++)
  typeof (function () { }) === 'function'
console.timeEnd("typeof (function () { }) === 'function'")

console.time("typeof (async function () { }) === 'function'")
for (let i = 0; i < TIMES; i++)
  typeof (async function () { }) === 'function'
console.timeEnd("typeof (async function () { }) === 'function'")
gives result
(() => { }) instanceof Function: 5490ms
(async () => { }) instanceof Function: 6884ms
(function () { }) instanceof Function: 5408ms
(async function () { }) instanceof Function: 6938ms
typeof (() => { }) === 'function': 1916ms
typeof (async () => { }) === 'function': 1998ms
typeof (function () { }) === 'function': 1976ms
typeof (async function () { }) === 'function': 1972ms
by გიორგი უზნაძე
3 years ago
JavaScript
Performance
0
Pro tip: use ```triple backticks around text``` to write in code fences