为了账号安全,请及时绑定邮箱和手机立即绑定

原型链还是搞不懂

老师,

这个prototype里的constructor属性有什么用处;

还有这些,

function person(){}
undefined
function student(){}
undefined
student.prototype = new person()
Object {  }
student.prototype.constructor
function person()
student.prototype.constructor = student()
undefined
student.prototype.constructor
undefined
student.prototype.constructor = student
function student()
student.prototype.constructor
function student()
var bosn = new student()
undefined
bosn instanceof person
true
person.prototype
Object { , 等 1 项… }
person.prototype.constructor
function person()
function one(){}
undefined
student.prototype.constructor
function student()
student.prototype.constructor = one
function one()
bosn instanceof person
true
bosn instanceof one
false
one.s = 9
9
bosn.s
undefined
student.prototype = new one()
Object {  }
bosn.s
undefined
bosn instanceof one
false
bosn instanceof person
true
student.prototype
Object {  }
bosn.z
undefined
person.z
undefined
person.prototype.z
undefined
person.prototype.z = 3
3
person.prototype.z
3
bosn.z
3
bosn.s
undefined
student.prototype
Object {  }
student.prototype.toString
function toString()
student.prototype.constructor
function one()
student.prototype = new one()
Object {  }
var v = new student()
undefined
v instanceof one
true
bosn instanceof one
false
bosn instanceof peoson
ReferenceError: peoson is not defined
bosn instanceof person
true
bosn.prototype = new one()
Object {  }
bosn instanceof person
true
bosn.prototype
Object {  }
bosn.prototype.constructor
function one()

为什么bosn instanceof person是true  我明明把student.prototype改了     为什么还是指向person

正在回答

2 回答

。。。。。。。。。。。

0 回复 有任何疑惑可以回复我~

你最好是截屏,而不是复制,这样一大段什么格式都没有,别人看不懂是什么的。所以才没有人回答你。

0 回复 有任何疑惑可以回复我~
#1

爱代码_爱前端 提问者

thanks
2015-05-01 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
JavaScript深入浅出
  • 参与学习       281118    人
  • 解答问题       1020    个

由浅入深学习JS语言特性,且解析JS常见误区,从入门到掌握

进入课程

原型链还是搞不懂

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信