Look pretty well. And it seems that it works:
But let me show you why this is a bad approach. I will change the value of field a, then delete it and will try to get its value:
One more example:
This is awful. We don’t need this.
We ended up with this result because when we’ve made this:
B.prototype = new A();
we just pushed a link to a new A object with all its properties and methods to the prototype of object B. So that when we try to take inherited property of object B we will always get the value of this property in object A which link is stored in the prototype of object B.
If you will try to apply previous examples to this approach you will see that now your code works as you expected.