js原型相关 笔试题一道

请写出下列代码的输出结果

var P = function(){}
p.prototype.aaa = function () {
    alert("ddd")
}

var a = new P(),
    b = new P();

b.prototype = p;
b.prototype.aaa = function() {
    alert("cc")
}

var c = Object.create(null),
    d = new Object();

console.log(P.__proto__); 
console.log(P.prototype); 
console.log(a.__proto__); 
console.log(a.prototype); 
console.log(b.prototype); 
console.log(c.__proto__); 
console.log(d.__proto__); 
console.log(Number.__proto__); 
console.log(Number.prototype); 
console.log(Function.__proto__); 
console.log(Function.prototype); 
console.log(Function.prototype.__proto__);
console.log(Object.__proto__); 
console.log(Object.prototype); 
console.log(Object.prototype.__proto__);

猜你喜欢

转载自blog.csdn.net/weixin_33806509/article/details/90807074
今日推荐