直接po图和代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>javaScript闭包中的this</title>
<script type="text/javascript">
function fn1() {
var num1 = 666.66;
console.log('我是函数中的this', this);
function fn2() {
console.log('我是函数中的函数,我的this是', this);
return this;
}
return fn2;
}
var result1 = fn1();
console.log(result1);
console.log('*****************');
var result2 = fn1()();
console.log(result2);
</script>
</head>
<body style="background-color: #CCE8CF;">
<h1 style="color: red;">javaScript闭包中的this</h1>
</body>
</html>