Skip to content

Instantly share code, notes, and snippets.

@santiago-puchginer-snkeos
Created May 5, 2016 22:23
Show Gist options
  • Save santiago-puchginer-snkeos/7fa146019f86854fee1eaea83eec28fd to your computer and use it in GitHub Desktop.
Save santiago-puchginer-snkeos/7fa146019f86854fee1eaea83eec28fd to your computer and use it in GitHub Desktop.
Closures in Javascript
// 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