let len = 10;
function fn() {
console.info(this.len)
}
fn(); // A
let Person = {
len: 5,
say: function() {
fn(); // B
arguments[0](); // C
}
}
Person.say(fn);
三处的输出结果均为 undefined
var length = 10;
function fn() {
console.info(this.length)
}
fn(); // A
let Person = {
len: 5,
say: function() {
fn(); // B
arguments[0](); // C
}
}
Person.say(fn);
分别输出 10, 10, 1
原文:https://www.cnblogs.com/peaky/p/js-this.html