Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. //creating proxies with proxy constructor.
  2. function car1(position) {
  3. this.position = position;
  4. }
  5.  
  6. const handler1 = {
  7. construct(target, args) {
  8. console.log('car1 constructor called');
  9. // expected output: "car constructor called"
  10.  
  11. return new target(...args);
  12. }
  13. };
  14.  
  15. const proxy1 = new Proxy(car1, handler1);
  16.  
  17. console.log(new proxy1('finish line').position);
  18. // expected output: "finish line"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement