Last active
May 11, 2016 17:13
-
-
Save w3cj/6aa78c47b0dcaa9e9762fc71ce7f394d to your computer and use it in GitHub Desktop.
When creating an iife, use a function, NOT a fat arrow. With a fat arrow, this is bound to the this of the surrounding code (in this case Window or Global), negating the use of an iife (to prevent polluting global scope).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When creating an iife, use a function, NOT a fat arrow. | |
// With a fat arrow, this is bound to the this of the surrounding code (in this case Window or Global). | |
// Therefore, using a fat arrow negates the use of an iife (to prevent polluting global scope). | |
(() => { | |
'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