Last active
December 12, 2015 03:49
-
-
Save cowboy/4710214 to your computer and use it in GitHub Desktop.
IIFE: the simplest example i can contrive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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