1
2
3
4
5
6
7
function tt() {
if (this === window) console.log("TRUE"); else console.log("FALSE");
var ttt = function () {
if (this === window) console.log("TRUE"); else console.log("FALSE");
};
ttt();
}
1
2
3
4
5
6
7
var tt = function () {
if (this === window) console.log("TRUE"); else console.log("FALSE");
var ttt = function () {
if (this === window) console.log("TRUE"); else console.log("FALSE");
};
ttt();
};
1
2
3
4
5
6
tt()
window.tt()
this.tt()
new tt()
new window.tt()
new this.tt()

1
2
3
4
5
6
7
function tt() {
if (this === window) console.log("TRUE"); else console.log("FALSE");
var ttt = function () {
if (this === window) console.log("TRUE"); else console.log("FALSE");
};
window.ttt(); // TypeError
}
1
2
3
4
5
6
7
function tt() {
if (this === window) console.log("TRUE"); else console.log("FALSE");
var ttt = function () {
if (this === window) console.log("TRUE"); else console.log("FALSE");
};
ttt.call(window);
}

1
2
3
4
5
6
7
8
function tt() {
"use strict";
if (this === undefined) console.log("TRUE"); else console.log("FALSE");
var ttt = function () {
if (this === undefined) console.log("TRUE"); else console.log("FALSE");
};
ttt();
}
1
2
3
4
5
6
7
8
var tt = function () {
"use strict";
if (this === undefined) console.log("TRUE"); else console.log("FALSE");
var ttt = function () {
if (this === undefined) console.log("TRUE"); else console.log("FALSE");
};
ttt();
};
1
2
3
4
5
6
tt()
window.tt()
this.tt()
new tt()
new window.tt()
new this.tt()

Comments

2017-08-16