Skip to content

Instantly share code, notes, and snippets.

@night-fury-rider
Last active September 17, 2020 04:06
Show Gist options
  • Save night-fury-rider/0d7f9e822376452fb7c205b89099922f to your computer and use it in GitHub Desktop.
Save night-fury-rider/0d7f9e822376452fb7c205b89099922f to your computer and use it in GitHub Desktop.
Design Pattern - Module
var Person = function(personName) {
var age = 30; // age will not be accessible outside of Person block
var name = 'Yuvraj';
return {
getName: function() {
return name;
}
}
};
var person1 = new Person();
console.log(person1.getName()); // Yuvraj
console.log(person1.age); // undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment