"The above code uses an IIFE (Immediately-invoked function expression) to produce a function with additional data"
I'm probably being a mindless pedant, but...
Having read the linked (Alman) article, I think this terminology is iffy at best. This is just a closure. You are using a second function to create a lexical scoping, but a closure without lexical scope is just an anonymous function. (Full name of a closure being a lexical closure).
If JavaScript had a 'let' construct to allow for lexical scoping without creating anonymous functions, this would be fairly easy to see.
But I think adding new terminology such as 'IFFE' obscures what a closure actually is.
The point of an IIFE is that it is immediately invoked, i.e.: `(function () { })()` - the outer function is used to return the inner function at that point. So you're returning the inner function, and it's this function, a closure, that is returned.
I'm not sure what's iffy about the terminology here...
I did not look at the article, but if you need to example "let" to someone, JavaScript 1.7 (Firefox) and ECMAScript4 have exactly that: a let statement for binding lexically scoped variables.
I'm probably being a mindless pedant, but...
Having read the linked (Alman) article, I think this terminology is iffy at best. This is just a closure. You are using a second function to create a lexical scoping, but a closure without lexical scope is just an anonymous function. (Full name of a closure being a lexical closure).
If JavaScript had a 'let' construct to allow for lexical scoping without creating anonymous functions, this would be fairly easy to see.
But I think adding new terminology such as 'IFFE' obscures what a closure actually is.