Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //creating proxies with proxy constructor.
- function car1(position) {
- this.position = position;
- }
- const handler1 = {
- construct(target, args) {
- console.log('car1 constructor called');
- // expected output: "car constructor called"
- return new target(...args);
- }
- };
- const proxy1 = new Proxy(car1, handler1);
- console.log(new proxy1('finish line').position);
- // expected output: "finish line"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement