<sod>An '''immediately-invoked function expression''' (or '''IIFE''', pronounced "iffy"<ref name=Alman>{{cite web|last=Alman|first=Ben|title=Immediately Invoked Function Expressions|url=http://benalman.com/news/2010/11/immediately-invoked-function-expression|year=2010|accessdate=4 February 2013}}</ref>) is a [[JavaScript]] design pattern which produces a [[scope (computer science)|lexical scope]] using JavaScript's [[function scoping]]. Immediately-invoked function expressions can be used to avoid [[JavaScript syntax#Scoping_and_hoisting|variable hoisting]] from within blocks, protect against polluting the [[Global variable|global environment]] and simultaneously allow public access to methods while retaining privacy for variables defined within the function. This pattern has been referred to as a '''self-executing anonymous function''',<ref>{{cite book|last=Resig|first=John|title=Pro JavaScript Techniques|year=2006|publisher=Apress|isbn=9781430202837|pages=29}}</ref> but Ben Alman introduced the term IIFE as a more semantically accurate term for the pattern, shortly after its discussion arose on comp.lang.javascript.<ref name=Alman /><ref name=Osmani>{{cite book|last=Osmani|first=Addy|title=Learning JavaScript Design Patterns|year=2012|publisher=O'Reilly|isbn=9781449334871|pages=206}}</ref><eod>
<sod>An '''immediately-invoked function expression''' (or '''IIFE''', pronounced "iffy"<ref name=Alman>{{cite web|last=Alman|first=Ben|title=Immediately Invoked Function Expressions|url=http://benalman.com/news/2010/11/immediately-invoked-function-expression|year=2010|accessdate=4 February 2013}}</ref>) is a [[JavaScript]] [[Programming_idiom|programming language idiom]] which produces a [[scope (computer science)|lexical scope]] using JavaScript's [[function scoping]]. Immediately-invoked function expressions can be used to avoid [[JavaScript syntax#Scoping_and_hoisting|variable hoisting]] from within blocks, protect against polluting the [[Global variable|global environment]] and simultaneously allow public access to methods while retaining privacy for variables defined within the function. This pattern has been referred to as a '''self-executing anonymous function''',<ref>{{cite book|last=Resig|first=John|title=Pro JavaScript Techniques|year=2006|publisher=Apress|isbn=9781430202837|pages=29}}</ref> but Ben Alman introduced the term IIFE as a more semantically accurate term for the pattern, shortly after its discussion arose on comp.lang.javascript.<ref name=Alman /><ref name=Osmani>{{cite book|last=Osmani|first=Addy|title=Learning JavaScript Design Patterns|year=2012|publisher=O'Reilly|isbn=9781449334871|pages=206}}</ref><eod>