如何在使用 javascript 模块模式的私有方法时访问 this(对象 this)?
我不明白这是如何工作的,我仍在努力学习它。
var o = o || {};
o.Assets = (function() {
"use strict";
function privateFunc() {
// how do I get this.assetQ?
}
function Assets(assetQ) {
this.init(assetQ);
};
Assets.prototype.assetQ = [];
Assets.prototype.cache = [];
Assets.prototype.callback = false;
/*
Initialize the assets
*/
Assets.prototype.init = function(assetQ) {
if (assetQ) {
this.assetQ = assetQ;
}
};
return Assets;
})();