function Human(){
this.job = 'code'
}
var developer = new Human();
console.log(developer.constructor);
Above Console Logs
function Human() {
this.job = 'code';
}
When I uncomment a line Human.prototype = {feeds: 'Pizza'};, its console logs
function Object() {
[native code]
}
Why does installing a prototype on a constructor function affect who is the constructor of the object created by the constructor?
Another example:
function LivingBeing() {
breathes: 'air';
}
function Human(){
feeds: 'Pizza';
}
var developer = new Human();
console.log(developer.constructor);
With a comment, as he says, the constructor of Human, when he does not comment on it, says LivingBeing. Why does the designer go further when something is really found on the prototype?
I thought to add another level to this
function AThing(){
this.say = function(){return 'I am thing';};
}
function LivingBeing() {
breathes: 'air';
}
LivingBeing.prototype = new AThing();
function Human(){
feeds: 'Pizza';
}
Human.prototype = new LivingBeing();
var developer = new Human();
console.log(developer.constructor);
Now its developer is the AThing developer. Can I say that the designer goes as far as possible in the prototype chain?
Saran source
share