Last active
September 17, 2020 04:06
-
-
Save night-fury-rider/0d7f9e822376452fb7c205b89099922f to your computer and use it in GitHub Desktop.
Design Pattern - Module
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 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