I've got this code piece below:
function me(){
this.age=30,
this.say=function(){return 'hello me'}
}
function child(){
this.hobby='sports'
}
child.prototype=new me();
var son=new child();
son.prototype=new me();
console.log(son.age);//30
console.log(son.__proto__.age);//30
console.log(son.constructor.prototype.age);//undefined
console.log(son.constructor.prototype.say())//exception
The printing result was, only the first 2 log prints out "30", all others prints out "undefined", and the last line even throws exception in runtime.
(1) I was expecting that all of them should give me output. Why the 3rd line prints 'undefined"?
(2) I expect that both "proto" and "constructor.prototype" has same effect, but actually not.