做了三件事
1 创建一个空对象 2 把this指向创建的空对象 ,并且把this的constructor指向构造函数 3 执行构造函数
如代码所示 构造函数就是Person this.constructor指向的就是Person
打印this可以看到this是一个空对象
<script>
function Perosn(name) {
console.log(this)
console.log(this.constructor)
this.name = name
}
let xiaoming = new Perosn('xiaoming')
console.log(xiaoming)
</script>