zoukankan      html  css  js  c++  java
  • js 原型链

    console.log(typeof Object)//null var o = {} ,var obj = new Object, new Dog()
            console.log(typeof Function)
            console.log(typeof Number)
            console.log(typeof Boolean)
            console.log(typeof String)
    
            //除了undefined js 其余5中类型的封装类型本质都是函数
            console.log(typeof undefined)
    
            console.log(typeof Date)
            console.log(typeof Array)
            
    
            console.log(Date.prototype)
            console.log(Object.prototype)
    
            console.log(Function.prototype)//function(){}

    上面是迷惑你的,下面才是干货:

    function Father(){
                this.p = 'p'
            }
    
            var f = new Father
    
            function Son(){
                
            }
            
            //Son 构造函数的原型对象 指向了f
            //这样就继承了f 的p 属性
            Son.prototype = f
    
            //Son 的实例中有一个__proto__记录了 原型对象 Son.prototype 也就是 对象f
            var s = new Son()
            console.log(s)
    
            //关键在于f 对象中也有一个 __proto__ 记录了它的原型对象 Father.prototype
    
            //..... 如此一层一层的实现了继承
    
            //终点是 null 这就是传说中的无中生有吧
            Object.prototype.__proto__
  • 相关阅读:
    liunx各命令及全称
    window启动数据库服务命令
    拉取github指定分支上的代码
    python项目学习
    客户展示 增删改查
    登录 注册功能 表梳理
    java简历
    go语言数组
    go语言 变量作用域
    go语言函数
  • 原文地址:https://www.cnblogs.com/xuezizhenchengxuyuan/p/6814244.html
Copyright © 2011-2022 走看看