I was looking into Javascript objects and prototypes, as far as I knew, the two ways of defining constructors ends up with similar results.
For example in this code the same exact constructors are defined in 2 different ways yet they end up with different prototype values:
var PersonOne = function () {};
function PersonTwo(){};
var p1 = new PersonOne();
var p2 = new PersonTwo();
console.log(p1.constructor.prototype);
console.log(p2.constructor.prototype);
result:
Object {}
PersonTwo {}
Obviously I was wrong about that and defining the constructor like in PersonOne results in a constructor who's prototype is Object. And that would affect inheritance. But the question is, what is the reason for such a different result?
I think the issue might be due to the fact that PersonOne function gets defined on run-time while PersonTwo on parse-time? Thanks for the help.