局部函数的直接引用与调用
<!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>
坚持下去就能成功