原型链详解

 

 

 

 

 

 

源码 :

 <script>
        //每一个 函数 都有个 __proto__ 和 prototype    函数.prototype.__proto__ ==函数.__proto__.__proto__
        //每一个对象 都个 __proto__    对象.__proto__ ==Object.prototype
        let A = function () {}
        let B = {}

        function User() {}
        let C = new User()
        console.dir(A, 'A函数') //__proto__   prototype
        console.dir(B, 'B对象') //__proto__
        console.dir(C, 'C实例对象') //__proto__
        console.dir(User, 'User实例对象') //__proto__  prototype

        console.log('============================')
        console.log(A.prototype, 'A函数')
        console.log(B.prototype, 'B对象')
        console.log(C.prototype, 'C实例对象')
    </script>

 

posted @ 2020-12-23 20:20  外行的小白  阅读(87)  评论(0)    收藏  举报