zoukankan      html  css  js  c++  java
  • js prototype 和constructor

    1.function 和object 都有 constructor 和prototype

    2. var a=new Animal() (animal 是function或Object) a 有 constructor  没有 prototype, a的constructor 是animal.prototype.constructor

    3.实例化的function 和Object 都有 constructor   是指向  被实例化的 prototype.constructor

    如 var a=new Animal();  // a.constructor===Animal.prototype.constructor  true      a 没有prototype  (function)

    var o =new Object() ;//obj.constructor===Object.prototype.constructor  true    o 没有prototype    (Object)

    4.Animal.constructor 是function(){}   Animal.prototype.constructor是本身函数

    function Anmal(name)

    {

     this.name=name;

    }

    Animal.constructor是

    function Function() {
        [native code]
    }

    Animal.prototype.constructor 是

    function Animal(name) {
                this.name =name
           
            }

  • 相关阅读:
    编译错误总结。
    9.7
    9.5
    9.6
    9.4
    9.3
    FutureTask取结果超时代码小测试
    java concurrent包常用类小结
    java Nio零散知识点整理
    java进阶教程unit_2java常用类(2)
  • 原文地址:https://www.cnblogs.com/tiancai/p/5501066.html
Copyright © 2011-2022 走看看