13_函数扩展.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. // function foo(a){
  38. // // if(a){
  39. // // console.log(a)
  40. // // }else{
  41. // // console.log("参数无效")
  42. // // }
  43. // a = a||"参数无效";
  44. // console.log(a);
  45. // }
  46. // foo();
  47. // var arr = new Array();
  48. // es6为参数提供默认值
  49. // function foo(a="hello"){
  50. // console.log(a);
  51. // }
  52. // foo();
  53. // function foo(a=1,b=2,c=3){
  54. // console.log(a,b,c)
  55. // }
  56. // foo("a","","b");
  57. // function foo(){
  58. // console.log("hell");
  59. // }
  60. // console.log(foo.name);
  61. // var foo = function foo2(){
  62. // console.log("1");
  63. // }
  64. // // foo2();
  65. // console.log(foo.name)
  66. // function foo(a,b,c){
  67. // console.log(a,b,c)
  68. // }
  69. // console.log(foo.length);
  70. </script>
  71. </body>
  72. </html>