13_函数扩展.html 939 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. // function foo(){
  11. // console.log("hello");
  12. // }
  13. // var foo = function(){
  14. // console.log("hello");
  15. // }
  16. // 箭头函数内部没有arguments
  17. // let foo = () => {
  18. // // console.log(arguments)
  19. // console.log("hello");
  20. // };
  21. // foo();
  22. var a = 10;
  23. // let obj = {
  24. // a : "hello",
  25. // foo:function(){
  26. // console.log(this.a)
  27. // }
  28. // }
  29. // 箭头函数内没有this
  30. let obj = {
  31. a : "hello",
  32. foo:()=>{
  33. console.log(this.a)
  34. }
  35. }
  36. obj.foo()
  37. </script>
  38. </body>
  39. </html>