kingport / webBlog

记录分享JS笔记
3 stars 0 forks source link

JS中的原型和原型链 #10

Open kingport opened 4 years ago

kingport commented 4 years ago

原型和原型链

image

image

kingport commented 4 years ago

JS new一个对象的过程

kingport commented 4 years ago

原型链

    function Supermarket() {
      Supermarket.prototype.product = '口罩'
    }
    function Shop() {
      Shp.prototype = new Supermarket()
    }
    var person = new Shop();
    console.log(person.product)