javascript - Object.define can monitor object changes, how to monitor basic type variables
仅有的幸福
仅有的幸福 2017-06-05 11:12:55
0
1
599
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"?

仅有的幸福
仅有的幸福

reply all(1)
小葫芦
Object.defineProperty(window, "mystring", {
    get : function(){ console.log("get");return this._name;},
    set: function(val){  console.log("set");this._name = val;}
});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!