Expose private variables in Revealing Module Pattern

后端 未结 3 1334
不知归路
不知归路 2021-02-04 11:29

I\'m trying to implement the Revealing Module Pattern but I\'m unable to expose a modified private property.

var myRevealingModule = (function(){

    var name =         


        
3条回答
  •  梦谈多话
    2021-02-04 12:13

    If your value is an attribute in an object or array, you can export the object or array and the export will be by reference so outside users will see updated changes. It's a little risky since the generic pattern of exporting variables has the scalar/object copy/reference dichotomy.

提交回复
热议问题