» Glossary » Immediately-Invoked Function Expression
In JavaScript lingo, IIFE means Immediately-Invoked Function Expression:
(function( yourGreeting ){
console.log( yourGreeting );
})( 'hello world' );
In this case, an alternative way to get the same result would be:
var doGreet = function( yourGreeting ){
console.log( yourGreeting );
}
doGreet( 'hello world' );
Both approaches make the code within isolated from the global scope, but the IIFE doesn't pollute it with new variables.
Recommended reading:
- Immediately-Invoked Function Expression, by Ben Alman, in which he coined the term.
- Namespace pattern
- Module pattern
- On JavaScrip modules