构造函数原型对象(一)

64 阅读1分钟

image.png

<script>
   function Person(name,age) {
       this.name = name
       this.age = age
   }
   Person.prototype.sing = function(){
    console.log('我喜欢唱歌');
   }
   let xyd = new Person('徐益栋',23)
   let zzy = new Person('周智莹',18)
   console.log(xyd);
   console.log(xyd.__proto__ === Person.prototype);
</script>

执行结果

image.png

简单小结:实例对象的隐式原型对象指向构造函数的显示原型对象