• Perfection Kills


     1 <!doctype html>
     2 <html>
     3 <head>
     4 <meta charset="utf-8">
     5 <title>无标题文档</title>
     6 <script>
     7     window.onload=function(){
     8         /*
     9         1.
    10         (function(){
    11             alert(typeof(arguments));    
    12         })();
    13         自执行函数,结果为object
    14         */    
    15         /*2.
    16         var f = function g(){ return 23; };
    17           alert(typeof g());*/
    18         //g只能在内部调用,结果为 g is not undefined
    19         
    20         /*3.(function(x){
    21             delete x;
    22             return x;
    23          })(1);*/
    24          //delete只能删除某个函数下的属性,不能删除变量以及参数,这里的x为形参,结果为1
    25          
    26          
    27          /*4.
    28          var y = 1, x = y = typeof x;
    29            alert(x);
    30          因为typeof返回的是字符串,并且表达式从右向左计算,因此结果为"undefined"*/
    31          
    32          /*5.
    33          (function f(f){
    34          return typeof f();
    35            })(function(){ return 1; });
    36          自执行函数,把1传给f,结果number*/
    37          
    38          /*
    39          6.
    40          var foo = {
    41             bar: function() { return this.baz; },//this指向foo.bar,但其实是window
    42             baz: 1
    43           };
    44          (function(){
    45                 return typeof arguments[0]();
    46           })(foo.bar);//结果为undefined*/
    47           
    48           /*7.
    49           var foo = {
    50                 bar: function(){ return this.baz; },
    51                 baz: 1
    52               }
    53               typeof (f = foo.bar)();
    54          ;*/
    55          
    56          /*8.
    57          var f = (function f(){ return "1"; }, function g(){ return 2; })();
    58            alert(typeof f);
    59          //分组选择符,返回最后面的那个值*/
    60          
    61          /*9.
    62          var x = 1;
    63           if (function f(){}) {
    64             x += typeof f;//1+undefined字符串连接
    65           }
    66           x;*/
    67           
    68           /*10.
    69           var x = [typeof x, typeof y][1];
    70             typeof typeof x;//返回字符串string*/
    71           
    72           /*11.
    73           (function(foo){
    74             return typeof foo.bar;
    75           })({ foo: { bar: 1 } });//只有foo一个属性,返回undefined*/
    76           
    77           /*12.
    78           (function f(){//函数声明预解析,结果为2,覆盖前面的1和2
    79             function f(){ return 1; }
    80             return f();
    81             function f(){ return 2; }
    82           })();*/
    83           
    84           /*13.
    85           function f(){ return f; }
    86             new f() instanceof f;//f()变成了f对象,结果为false*/
    87           
    88           /*14.
    89            with (function(x, undefined){}) length;
    90            //计算函数的长度,即参数的个数,结果为2*/
    91          }
    92 </script>
    93 </head>
    94 <body>
    95 </body>
    96 </html>

     网址:http://perfectionkills.com/

    念念不忘,必有回响。
  • 相关阅读:
    【贪心】时空定位I
    【贪心】删数问题
    【贪心】取火柴游戏
    【贪心】均分纸牌
    Fix a Tree
    Vacations
    One Bomb
    Abandoned country
    BZOJ 1006 [HNOI2008]神奇的国度
    BZOJ 2118 墨墨的等式
  • 原文地址:https://www.cnblogs.com/paxster/p/3478631.html
Copyright © 2020-2023  润新知