Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//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
You can’t perform that action at this time.