这个原型链的问题我弱弱的问下为啥没有

wear112233 2017-05-27 12:06:40
window.onload=function(){
function first(){
this.firstV=1;
};
first.prototype.getFirstVal=function(){
return this.firstV;
};
function second(){
this.secondV=2;
}
second.prototype=new first();

second.prototype.getSecondVal=function(){
return this.secondV;
}
function third(){
this.thirdV=3;
}
third.prototype=new second();
third.prototype.getThirdVal=function(){
return this.thirdV;
}
alert(second.prototype.getSecondVal());
...全文
80 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wear112233 2017-05-27
  • 打赏
  • 举报
回复
new first(); 不是实例化了吗
似梦飞花 2017-05-27
  • 打赏
  • 举报
回复
有啊 只是你没实例化 所以this.xxx没赋值 所以undefined了

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧