Immediately-invoked function expression

An immediately-invoked function expression (or IIFE, pronounced "iffy") is a JavaScript design pattern which produces a lexical scope using JavaScript's function scoping.

	// all your code here
	var foo = function() {};
	window.onload = foo;
	// ...
// foo is unreachable here (it's undefined)

This pattern is often used when trying to avoid polluting the global namespace, because all the variables used inside the IIFE (like in any other normal function) are not visible outside its scope.

and note also:

In ES6, the above IIFE can be rewritten using the arrow function

((foo) => foo)('foo value')