Jump to content

Talk:Immediately invoked function expression

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by The Transhumanist (talk | contribs) at 00:15, 12 April 2017 (top: Add WikiProject tag using AWB). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconJavaScript Unassessed
WikiProject iconThis article is within the scope of WikiProject JavaScript, a collaborative effort to improve the coverage of articles related to JavaScript, and to the development of user scripts for use on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
???This article has not yet received a rating on Wikipedia's content assessment scale.
???This article has not yet received a rating on the importance scale.

Note that code samples from Alman's page are licensed under the GPL and so may be used with attribution.

This code snippet is incorrect:

var v, getValue;
v = 1;
getValue = (function(v) {
  return v;
}(v));
v = 2;
 
getValue(); // 1

`getValue` is the number 1, not a function. 88.90.244.215 (talk) 19:40, 3 April 2013 (UTC) Later yo[reply]

Parentheses

The Usage section says: a common convention is to enclose both the function expression and invocation in parentheses but the following example (the one with the parameters) does not follow this convention (the invocation is not enclosed).

I changed that example in order to have both expression and invocation enclosed in parentheses. --Mariana de El Mondongo (talk) 00:28, 24 February 2015 (UTC)[reply]