1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- // function foo(){
- // console.log("hello");
- // }
- // var foo = function(){
- // console.log("hello");
- // }
- // 箭头函数内部没有arguments
- // let foo = () => {
- // // console.log(arguments)
- // console.log("hello");
- // };
- // foo();
- var a = 10;
- // let obj = {
- // a : "hello",
- // foo:function(){
- // console.log(this.a)
- // }
- // }
- // 箭头函数内没有this
- // let obj = {
- // a : "hello",
- // foo:()=>{
- // console.log(this.a)
- // }
- // }
- // obj.foo()
- // function foo(a){
- // // if(a){
- // // console.log(a)
- // // }else{
- // // console.log("参数无效")
- // // }
- // a = a||"参数无效";
- // console.log(a);
- // }
- // foo();
- // var arr = new Array();
- // es6为参数提供默认值
- // function foo(a="hello"){
- // console.log(a);
- // }
- // foo();
- // function foo(a=1,b=2,c=3){
- // console.log(a,b,c)
- // }
- // foo("a","","b");
- // function foo(){
- // console.log("hell");
- // }
- // console.log(foo.name);
- // var foo = function foo2(){
- // console.log("1");
- // }
- // // foo2();
- // console.log(foo.name)
- // function foo(a,b,c){
- // console.log(a,b,c)
- // }
- // console.log(foo.length);
- </script>
- </body>
- </html>
|