Member-only story
JavaScript Basics: How to create private & public functions in JavaScript with the Module Pattern
I’m gonna show you how you can create private functions and public methods with Vanilla JavaScript using the Module Pattern (Object Literal).
JavaScript Module Pattern
In my opinion, the JavaScript Module Pattern is the way to structure your JavaScript into more reusable pieces of code.
But today I’m not gonna talk about everything of that Module Pattern. Today I’m gonna show you how you can create private functions and public methods.
Private function
A private functions is private, because it is not accessible form outside the module.
Public method
A public method is just like the private one a function. But a function inside a Object is called a method.
Maybe experienced developers will tell, my explanation is to easy. Please explain in the comments!