var obj = {};
Object.defineProperty(obj, "name", {
get : function(){ return this._name;},
set: function(val){ this._name = val;}
});
How to monitor the string variable changes of var string="a"?
高洛峰2017-06-05 11:14:55
Object.defineProperty(window, "mystring", {
get : function(){ console.log("get");return this._name;},
set: function(val){ console.log("set");this._name = val;}
});