var obj = {}; Object.defineProperty(obj, "name", { get : function(){ return this._name;}, set: function(val){ this._name = val;} });
Wie kann man also Änderungen in der String-Variablen von var string="a" überwachen?
Object.defineProperty(window, "mystring", { get : function(){ console.log("get");return this._name;}, set: function(val){ console.log("set");this._name = val;} });