| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <!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>
- // 第一题
- // var n = 13;
- // function fn(n) {
- // alert(n);//13
- // n = 14;
- // alert(n);//14
- // }
- // fn(n);
- // alert(n)//13
- // 第二题
- // var n = 0;
- // function a() {
- // var n = 10;
- // function b() {
- // n++;
- // alert(n);//11
- // }
- // b();
- // }
- // a();
- // alert(n);//0
- // 第三题
- // console.log(num, str);//undefined undefined
- // var num = 18;
- // var str = "lily";
- // function fn2() {
- // console.log(str, num);// lily undefined
- // num = 19;
- // str = "candy";
- // var num = 14;
- // console.log(str, num);// candy 14
- // }
- // fn2();
- // console.log(str, num);// candy 18
- // 第四题
- // fn();//2
- // function fn() { console.log(1) };
- // fn();//2
- // var fn = 13;
- // // fn();//fn is not a function
- // function fn() { console.log(2) };
- // // fn();fn is not a function
- // 第五题
- // (function f() {
- // function f() { console.log(1) };
- // f();//2
- // function f() { console.log(2) };
- // })();
- // 第六题
- // if (!("a" in window)) {
- // var a = 10;
- // }
- // alert(a);//undefined
- // console.log(fn);//undefined
- // if (9 == 8) {
- // function fn() {
- // alert(2);
- // }
- // }
- // in 运算符 判断对象是否有某个属性
- // var ojb = {
- // a:1,
- // b:2,
- // c:3
- // }
- // console.log("d" in ojb);
- // 第七题
- // function fn() {
- // var i = 5;
- // return function (n) {
- // console.log(n * i++);
- // }
- // }
- // var f = fn();
- // f(4);//20
- // fn()(5);//25
- // f(6);//36
- // function foo(){
- // var a = 1;
- // console.log(a);
- // }
- // // 函数每次调用都会生成一个新的作用域
- // foo();
- // foo();
- </script>
- </body>
- </html>
|