var obj = {}; Object.defineProperty(obj, "name", { get : function(){ return this._name;}, set: function(val){ this._name = val;} });
Alors, comment surveiller les changements dans la variable chaîne de var string="a" ?
Object.defineProperty(window, "mystring", { get : function(){ console.log("get");return this._name;}, set: function(val){ console.log("set");this._name = val;} });