0
我期待看到:
設置自動創建屬性不起作用
獲取
可有人請向我解釋爲什麼這個代碼不工作?感謝
var myObj = new MyObj();
function CreateSimpleProperty(propertyName) {
Object.defineProperty(myObj, propertyName, {
set: function (aVal) {
this[propertyName] = aVal;
console.log("Setting");
},
get: function() {
console.log("Getting");
return this[propertyName];
}
});
}
CreateSimpleProperty("TEST");
Overlay.TEST = 15;
console.log(Overlay.TEST);
什麼是疊加? – Nemoy