JS

坑爹面试题

Posted by Joel on April 06,2019

题目

1
2
3
4
5
6
7
8
9
10
function func(num) {
this.a = num
return this
}

a = func(1)
b = func(10)

console.log(a.a) // ?
console.log(b.a) // ?

问题在于a会被挂在window上,所以第二次调用函数后,a === window.a === 10
因此答案为undefined10


EOF


>