我试图实现透露出模块模式,但我无法暴露修改的私有财产暴露私有变量。揭示模块模式
var myRevealingModule = (function(){
var name = 'Diogo';
function setName() {
name = name + ' Cardoso';
}
return {
fullName: name,
set: setName
};
}());
// Sample usage:
myRevealingModule.set();
console.log(myRevealingModule.fullName); // "Diogo" instead of the excepted "Diogo Cardoso".