Skip to content

Instantly share code, notes, and snippets.

@ansarisufiyan777
Last active September 2, 2019 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ansarisufiyan777/bde88242ca8f4b8ce1165c2e4182b212 to your computer and use it in GitHub Desktop.
Save ansarisufiyan777/bde88242ca8f4b8ce1165c2e4182b212 to your computer and use it in GitHub Desktop.
//Module design patterns
exports.RunModular = () => {
Employee = (() => {
var emp = [];
console.log("Modular Pattern:", this)
// I am private
function privateFunction() {
console.log("Private function")
}
// I am public
function push(name) {
emp.push(name)
}
// I am public
function fetch() {
return emp;
}
return {
add: push,
fetch: fetch
}
})();
console.log(Employee.add("A1"))
console.log(Employee.add("A2"))
console.log(Employee.add("A3"))
console.log(Employee.fetch())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment