Guest User

Untitled

a guest
Aug 20th, 2019
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2. Function.prototype.apply2 = function(...rest)
  3. {
  4. let context = rest[0];
  5. let args = rest[1];
  6. context = context?context:window;
  7. context.fn = this;
  8. let res = context.fn(...args);
  9. delete context.fn;
  10. return res;
  11. }
  12. function bar(name,age)
  13. {
  14. console.log(this.value);
  15. console.log(name,age);
  16. return {
  17. name:name,
  18. age:age,
  19. value:this.value
  20. }
  21. }
  22. let obj = {
  23. value:66
  24. }
  25. let hh = bar.apply2(obj,["liu",22]);
  26. console.log(hh);
  27. }
RAW Paste Data