Skip to content

Instantly share code, notes, and snippets.

@wjx0912
Created July 26, 2022 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wjx0912/d35334195ca92d25940086ba533e652d to your computer and use it in GitHub Desktop.
Save wjx0912/d35334195ca92d25940086ba533e652d to your computer and use it in GitHub Desktop.
js_question
var name = 'window'
var person1 = {
name: 'person1',
foo1: function () {
console.log(this.name)
},
foo2: () => console.log(this.name),
foo3: function () {
return function () {
console.log(this.name)
}
},
foo4: function () {
return () => {
console.log(this.name)
}
}
}
var person2 = { name: 'person2' }
person1.foo4.call(person2)() // 为什么输出的是'person2'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment