index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. let d = arguments[1]('./t.js');
  2. console.log(d);
  3. function abc() {
  4. let obj = {
  5. name: '15'
  6. }
  7. obj.__proto__ = {
  8. bb(str) {
  9. console.log(str);
  10. },
  11. };
  12. obj.__proto__.constructor = function() {
  13. }
  14. return obj
  15. }
  16. function fn(that, cb) {
  17. return function() {
  18. cb.call(that)
  19. }
  20. }
  21. abc.prototype.sayHello = function() {
  22. setTimeout(new fn(this, function() {
  23. console.log(`你好,我叫${this.name}`);
  24. }), 15);
  25. }
  26. let b = new abc();
  27. console.log(b.name); //{ name: '15' }
  28. console.log(typeof b); //obj
  29. console.log(abc.sayHello);
  30. b.bb('-------'); //-------
  31. console.log(b.sayHello); //undefined
  32. function abc3() {
  33. this.name = 'n'
  34. }
  35. abc3.prototype.sayHello = function() {
  36. console.log(`你好,我叫${this.name}`);
  37. }
  38. // abc3.sayHello();
  39. //error
  40. // let c = new(() => {
  41. // let obj = {
  42. // name: '15'
  43. // }
  44. // obj.__proto__ = this;
  45. // return obj
  46. // })();
  47. // console.log(c);
  48. //ok
  49. let a = () => {
  50. console.log(arguments);
  51. };
  52. // console.log(arguments);
  53. arguments[2]