

Zen and the art of statefulness - skilldrick
http://skilldrick.co.uk/2011/02/zen-and-the-art-of-statefulness/

======
ohyes
"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.

~~~
skilldrick
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...

