Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function () {
- 'use strict';
- let user = {};
- let proxy = new Proxy(user, {
- get(target, prop) {
- console.log(`Чтение ${prop}`);
- return target[prop];
- },
- set(target, prop, value) {
- console.log(`Запись ${prop} ${value}`);
- target[prop] = value;
- return true;
- }
- });
- proxy.firstName = "Ilya"; // write
- proxy.firstName; // read
- console.log(user.firstName); // Ilya
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement