我正在寻找一种方法来强制我的所有对象在原型中都有自己的对象实例。原型中的这个对象有它自己的私有变量。我不想分享这些对象。我应该怎么办?
new function () {
"use strict";
function Controls() { };
Controls.prototype = new Application.Utils.Map(); //instance of this object is shared between all of new Controls objects. I want have new Map object for each new Controls Object.
Application.Stored.UI.Controls = new Controls();
Application.Stored.UI.Controls2 = new Controls();
}();
地图对象如下所示:
function(){
//private variables with methods
return {
func: someFunc,
...
};
};
如何做到这一点?