局部函数的直接引用与调用

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<script>
    var foo = {
        a:10,
        that:this.a,
        cool:function(){
            console.log(that)
        }
    }
    var a = 20;
//    1、直接在全局环境中调用;
    foo.cool();
//    2、直接在全局环境中调用;
   var t1 = setTimeout(function(){
        foo.cool()
    },10);
//    3、在全局环境中引用,然后在执行;
    var t2 = setTimeout(foo.cool,20)
</script>
</body>
</html>



posted @ 2015-11-26 10:10  挥刀  阅读(294)  评论(0编辑  收藏  举报