这段代码执行后,打印的结果是什么,为什么会是这样? ```js funct...
发布于 2022-03-03 17:15:05
这段代码执行后,打印的结果是什么,为什么会是这样?
```js
function test() {
getName = function() {
Promise.resolve().then(() => console.log(0))
console.log(1)
}
return this }
test.getName = function() {
setTimeout(() => console.log(2), 0)
console.log(3)
}
test.prototype.getName = function() {
console.log(4)
}
var getName = function() {
console.log(5)
}
function getName() {
}
test.getName()
getName()
test().getName()
getName()
new test.getName()
new test().getName()
new new test().getName()
```
关注者
0
被浏览
63