Create a gist now

Instantly share code, notes, and snippets.

IIFE: the simplest example i can contrive
var value, getValue;
value = 1;
getValue = function() { return value; };
value = 2;
getValue() // 2
var value, getValue;
value = 1;
getValue = (function(v) {
return function() { return v; };
}(value));
value = 2;
getValue() // 1
var value, getValue;
value = 1;
(function(v) {
getValue = function() { return v; };
}(value));
value = 2;
getValue() // 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment