IIFE vs Normal function
Date tested:
4 years ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
Test name
Executions per second
iifeFn
2473.7 Ops/sec
normalFn
1602.3 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
var iifeFn = (() => { return window.location !== window.parent.location; })(); var normalFn = () => { return window.location !== window.parent.location; };
Tests:
iifeFn
console.log(iifeFn)
normalFn
console.log(normalFn())
Open this result on MeasureThat.net