// case 1
function Person(name) {
this.name = name
}
const a = new Person('dylan')
Person.prototype = {
age: 10
}
console.log(a.age)
// case 2
function Person(name) {
this.name = name
}
const a = new Person('dylan')
Person.prototype.age = 10
console.log(a.age)
let prot = {}
function consTest (name) {
this.name = name
this.prot = prot
}
const c = new consTest('dylan')
prot = { age: 10}
const d = new consTest('d')
console.log(c, d)
依次输出
undefined
和10
理解了整个流程我们mock验证一下
其实这题侧重的还是引用类型和函数执行的理解