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 Mariana de El Mondongo (talk | contribs) at 00:28, 24 February 2015 (Parentheses: new section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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]