标签:
var Person = function(name) {};
Person.prototype.say = function() {
console.log("Person say");
}
Person.prototype.age = 20;
var Man = function() {};
Man.prototype = new Person();
Man.prototype.physique = ‘strong‘;
Man.prototype.age = 25;
var man = new Man();
man.say();
console.log(man.physique)
console.log(man.age);
//实例的__proto__ 指向的对象原型prototype
console.log(man.__proto__ === Man.prototype);
console.log(man.constructor === Person);
console.log(man.__proto__.constructor === man.constructor);
//对象的__proto__指向的都是Function的prototype
console.log(Person.constructor == Function);
console.log(Person.__proto__ == Function.prototype);
console.log(Person.__proto__.constructor == Function);
console.log(Person.prototype.constructor === Person);
console.log(Person.prototype.__proto__ === Object.prototype);
console.log(Function.constructor === Function);
console.log(Function.prototype.constructor === Function);
console.log(Function.__proto__.constructor === Function);
//Function.__proto__ 、 Object.__protot__ 和Function.prototype 指代就是同一个对象funtion
console.log(Function.prototype===Function.__proto__);
console.log(Function.prototype===Object.__proto__);
console.log(Object.prototype.__proto__=== null);
console.log(Object.__proto__.constructor == Function);
标签:
原文地址:http://www.cnblogs.com/river-lee/p/4483709.html