Immediately invoked function expression: Difference between revisions

Content deleted Content added
typo
MOD31P (talk | contribs)
m Added additional way to pass variables into IIFE
 
Line 21:
 
Passing variables into the scope is done as follows:
<syntaxhighlight lang="JavaScriptjavascript">
(function(a, b) { /* ... */ })("hello", "world");
(function(a="hello", b="world") { /* ... */ })(); //also works
</syntaxhighlight>