this IV
2022年5月1日小于 1 分钟
this
IV
Question
What does the code snippet to the right output by console.log
?
Snippet
var bar = 1
function foo() {
return this.bar++
}
const a = {
bar: 10,
foo1: foo,
foo2: function() {
return foo()
},
}
console.log(a.foo1.call())
console.log(a.foo1())
console.log(a.foo2.call())
console.log(a.foo2())