• 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__
  • 相关阅读:
    Some good websites for C++
    Static Class in C#
    js提示后跳转代码集合
    日期格式化函数
    URL伪静态
    正则的一些使用
    提高.net网站的性能
    验证DropDownList的方法
    用C#去除字符串中HTML的格式
    drepdownlist不能动态绑定数据的原因
  • 原文地址:https://www.cnblogs.com/xuezizhenchengxuyuan/p/6814244.html
Copyright © 2020-2023  润新知