美文网首页
js原型相关 笔试题一道

js原型相关 笔试题一道

作者: 切磋琢磨_FE | 来源:发表于2019-05-30 17:38 被阅读0次

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

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__);

相关文章

网友评论

      本文标题:js原型相关 笔试题一道

      本文链接:https://www.haomeiwen.com/subject/jjrvtctx.html