a few seconds read (About 95 words)
Proxy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| const obj = new Proxy( {}, { get: function(target, key, receiver) { console.log(`getting ${key}!`); return Reflect.get(target, key, receiver); }, set: function(target, key, value, receiver) { console.log(`setting ${key}!`); return Reflect.set(target, key, value, receiver); } } );
obj.count = 1 ++ obj.count
|
1 2
| ES6原生提供的Proxy构造函数: var proxy = new Proxy()
|