It's my understanding the Javascript Module Pattern simulates classes found in class-based languages, but I haven't been able to find an example of an object being instantiated using this pattern. In Java, classes are instantiated like this:
var myClassInstance = new MyClass();
All the Module Pattern tutorials I've seen explain the creation of a module with this basic syntax:
var MyModule = (function(){
var privateMember = 'foo';
function publicMember() {
}
return {
publicMember: publicMember
}
}());
- How would I then create a new instance of
MyModulein this example? - Are modules meant to be instantiated?
- What's the proper way to instantiate an object using the Module Pattern?
Aucun commentaire:
Enregistrer un commentaire