this II
2022年5月1日小于 1 分钟
this
II
Question
What does the code snippet to the right output by console.log
?
ref: https://javascript.info/reference-type
Snippet
const obj = {
a: 1,
b() {
return this.a
}
}
console.log(obj.b())
console.log((true ? obj.b : a)())
console.log((true, obj.b)())
console.log((3, obj['b'])())
console.log((obj.b)())
console.log((obj.c = obj.b)())