I am trying to understand how create different instances of revealing module pattern. I have a code block below and create module1 and module2 instances of myRevealingModule and setting their name variables.But name of module1 is overwritten by module2. How can i have different name values for module1 and module2? What am i missing? Thanks!
var myRevealingModule = (function(){
var name = 'Default';
function setName (nameVal) {
name = nameVal;
};
function getName () {
return name;
};
return {
fullName: name,
set: setName,
get: getName
};
}());
var module1 = myRevealingModule;
module1.set("module1 name");
var module2 = myRevealingModule;
module2.set("module2 name");
Aucun commentaire:
Enregistrer un commentaire