Document
< ;script>
var stu ={
m: function(){
var self = this;
console.log(this === stu); // ==> true;
function f(){
// When calling a nested function, this does not point to the context of calling the outer function
console.log(this === stu); // ==> false;
If you want to access the this of the external function, you need to save the this of the external function in a variable.
console.log(self === stu); // ==> true;
}
f();
}
}