Skip to content

Instantly share code, notes, and snippets.

@connoro7
Created July 16, 2020 19:24
Show Gist options
  • Save connoro7/4760d0c3cc1a55edcefc648a40948d2b to your computer and use it in GitHub Desktop.
Save connoro7/4760d0c3cc1a55edcefc648a40948d2b to your computer and use it in GitHub Desktop.
Arrow Function vs. Functional IIFEs

Arrows Functions vs. Function IIFEs

When creating an IIFE, use a regular function, NOT an arrow function.

With a fat arrow, this is bound to the this of the surrounding code (in this case Window or Global).

(() => {
  'use strict';
  
  console.log('fat arrow', this)
})();

(function(){
  'use strict';

  console.log('function', this)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment