I have this modified bit of code, from an online source, that discusses prototype inheritance.
var myObj = function() {}; // start w a regular func
myObj.prototype.a = 1; // attach properties to property
myObj.prototype.b = 2;
console.log('myObj dir a is: ' + myObj.a); // undefined
var myRealObj = new myObj();
console.log('my real obj a is: ' + myRealObj.a); // works
My bit of confusion is the first log statement where a is undefined. Even though it's in the prototype chain above the function should it not walk the chain? Why does it work when I use new to create an object instead?
Thanks!