this III
2022年5月1日小于 1 分钟
this
III
Question
What does the code snippet to the right output by console.log
?
Snippet
const obj = {
a: 1,
b: this.a + 1,
c: () => this.a + 1,
d() {
return this.a + 1
},
e() {
return (() => this.a + 1)()
}
}
console.log(obj.b)
console.log(obj.c())
console.log(obj.d())
console.log(obj.e())