js prototype 和constructor

1.function 和object 都有 constructor 和prototype函数

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

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

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

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

 

4.Animal.constructor 是function(){}   Animal.prototype.constructor是自己函数function

 

function Anmal(name)object

{im

 this.name=name;co

}constructor

Animal.constructor是

function Function() {
    [native code]
}

Animal.prototype.constructor 是

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

相关文章
相关标签/搜索