I'm trying to use prototypal inheritance, but I'm having trouble.
This doesn't work
var Parent = function(){
}
var Child = function(){
this.__proto__ = new Parent();
}
var child = new Child();
console.log(child instanceof Child) //logs false
But this does
var Parent = function(){
}
var Child = function(){
}
Child.prototype = new Parent();
var child = new Child();
console.log(child instanceof Child) // logs true
The only reason why I want the first option is so that I can leverage the parent's constructor. I'm guessing this
is the problem, but I'm not that great at javascript. How do I make this work?