Immediately invoked function expression: Difference between revisions

Content deleted Content added
Adds IPA transcription
reword intro. the idiom is notable for being used in Javascript, but it's not a Javascript-only idiom. Also it's basically dead because modules got added to ES6
Line 1:
 
An '''immediately invoked function expression''' (or '''IIFE''', pronounced "iffy", [[International Phonetic Alphabet|IPA]] /ˈɪf.i/) is a [[Programming idiom|programming language idiom]] which produces a [[scope (computer science)|lexical scope]] using [[function scoping]]. It was popular in [[JavaScript]]<ref name="Alman">{{cite web|url=http://benalman.com/news/2010/11/immediately-invoked-function-expression/|title=Immediately Invoked Function Expressions|last=Alman|first=Ben|date=15 November 2010|website=|url-status=live|archive-url=https://web.archive.org/web/20171201033208/http://benalman.com/news/2010/11/immediately-invoked-function-expression/|archive-date=1 December 2017|accessdate=18 January 2019}}</ref> isas a method to support [[JavaScriptmodular programming]] [[Programmingbefore idiom|programmingthe languageintroduction idiom]]of whichmore producesstandardized asolutions such as [[scopeCommonJS]] (computerand science)[[ECMAScript#6th Edition – ECMAScript 2015|lexicalES scopemodules]].<ref>{{cite usingweb |last1=McGinnis |first1=Tyler |title=JavaScript's [[functionModules: scoping]]From IIFEs to CommonJS to ES6 Modules |url=https://ui.dev/javascript-modules-iifes-commonjs-esmodules/ |website=ui.dev |access-date=18 August 2021 |language=en |date=15 January 2019}}</ref>
 
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.
Line 122:
 
== See also ==
*[[Evaluation strategy]]
*[[Reduction strategy (code optimization)|Reduction strategy]] in [[lambda calculus]]
 
== References ==