Created
May 5, 2016 22:23
-
-
Save santiago-puchginer-snkeos/7fa146019f86854fee1eaea83eec28fd to your computer and use it in GitHub Desktop.
Closures in Javascript
This file contains 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
// Snippet for closures | |
// A closure is a special kind of object that combines two things: a function, | |
// and the environment in which that function was created | |
function Person(name) { | |
var _name = name; // Private variable name | |
this.getName = function() { | |
return _name; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment