I tried experimenting with private variables and prototypes that didn't use IIFE (which makes objects global so no unique instances).
I tried the following and I'm confused by what I see. I can see it perfectly in the inspector that it's defined but it tells me it's actually not undefined.
What exactly is going on that makes it undefined despite seeing it defined in the inspector?
var Factory = Factory || {};
Factory.Person = function (aname)
{
var name = 'default';
function Person()
{
name = aname;
}
Person.prototype.getName = function() {
return name;
}
return Person;
};
var P = new Factory.Person('test');
alert(P.getName()); //Undefined