I was experimenting with inheritance and creating objects and somehow this confused me.
a = function (){console.log("test"); return "hello"};
b = new a();
//console output
test VM719:2
a {}
What does this mean ? Does it mean b contains a ? if so then if I do this
console.log(b.a);
//console output
undefined
undefined
Why this is so ? Secondly if I do this
b.__proto__
//console output
Object {}
a.prototype.test ="hello";
b.__proto__
//console output
Object {test: "hello"}
This is fine as new causes b s prototype to point to a.
console.log(b);
//console output
a {test: "hello"}
What does this output mean ? When i log b.test it gives "hello" but when i log b.a it gives "undefined" .So what is the significance of a in the output console ?