Es6 syntax (Proxy and Reflect), es6reflect
As follows:
{// Original object let obj = {time: '2017-03-11 ', name: 'net', _ r: 2017}; // (agent) the first parameter proxy object, let monitor = new Proxy (obj, {// block reading get (target, key) {return target [key] of object attributes. replace ('123', '123')}, // sets the property set (target, key, value) of the interception object {if (key = 'name ') {// assign a value and return target [key] = value;} else {// return target [key] directly without any operation}, // intercept key in object operation has (target, key) {if (key = 'name') {return target [key]} el Se {return false ;}}, // intercept delete deleteProperty (target, key) {if (key. indexOf ('_')>-1) {delete target [key]; return true;} else {return target [key]}, // intercept Object. keys, Object. getOwnPropertySymbols, Object. getOwnPropertyNames ownKeys (target) {return Object. keys (target ). filter (item => item! = 'Time')}); console. log ('get', monitor. time); // 2013-3-11 // operate the monitor. time = '000000'; monitor. name = 'mukewang'; console. log ('set', monitor. time, monitor); //; {time: "", name: "mukewang", _ r: 123} console. log ('has', 'name' in monitor, 'time' in monitor); // true; false delete monitor. time; console. log ('delete', monitor); // {time: "", name: "mukewang", _ r: 123} // delete monitor. _ r; console. log ('delete', monitor); // {time: "2017-03-11", name: "mukewang"} console. log ('ownerkeys ', Object. keys (monitor); // ["name", "_ r"]} {let obj = {time: '2017-03-11 ', name: 'net ', _ r: 123}; console. log ('reflect get', Reflect. get (obj, 'time'); // get 2017-03-11 Reflect. set (obj, 'name', 'mukewang'); console. log (obj); // {time: "", name: "mukewang", _ r: 123} console. log ('has', Reflect. has (obj, 'name'); // true}
The above discussion of es6 syntax (Proxy and Reflect comparison) is all the content shared by the editor. I hope to give you a reference, and I hope you can also support the help house.