构造函数本身就是个函数,也可以不记这个名字。重要的是new这其中的过程

function fn(name,age){
    this.name = name
    this.age = age
}

1.new fn(),创建一个对象

const obj = new fn('tom', 18)

2.this指向新的对象

3.执行构造函数的代码,修改值

4.形成对象

就算两个对象的内容完全一样,它俩也是不同的

function fn(name, age){
   
    this.name = name
    this.age = age
}
const ldj = new fn('fda',12)
const dfd = new fn('fda',12)
console.log(ldj)
console.log(dfd)
console.log(ldj === dfd)