Read this, it contains the detailed explanation of js classes, and how to make the private, public etc.
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.
- Closures: By creating closures, you can create private variables and methods that are only accessible within a specific scope.
- Object properties: You can use object properties to simulate the concept of private variables. You can set properties as non-enumerable or write-only, which makes them difficult to access from outside the object.
- WeakMap: You can use WeakMap to store private data associated with an object. The private data stored in a WeakMap cannot be accessed or enumerated.
- Symbol: You can use the Symbol type to create unique keys that can be used as private property names.
- Modules: You can use the module pattern to create private variables and methods that are only accessible within the scope of the module.