IIFE vs function with .call (named and unnamed)

Benchmark created by Tobias Krogh on


Preparation HTML

<div id="foobar"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
IIFE
(function() {
  var foo = document.getElementById("foobar");
})();
ready
IIFE (named)
(function getFoo() {
  var foo = document.getElementById("foobar");
})();
ready
function with .call
(function() {
  var foo = document.getElementById("foobar");
}).call(this);
ready
function with .call (named)
(function getFoo() {
  var foo = document.getElementById("foobar");
}).call(this);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Tobias Krogh on