asked on
function Person(firstName, lastName) {
var _firstName = firstName;
var _lastName = lastName;
Person.prototype.__defineGetter__("firstName", function() {
return _firstName;
});
Person.prototype.__defineSetter__("firstName", function(value) {
_firstName = value;
});
Person.prototype.__defineGetter__("lastName", function() {
return _lastName;
});
Person.prototype.__defineSetter__("lastName", function(value) {
_lastName = value;
});
};
var p1 = new Person("John", "Doe");
console.log(p1.firstName); // Prints John
console.log(p1.lastName); // Prints Doe
function Dignitary() {
};
Dignitary.prototype = new Person(); // making Dignitary inherit Person
Dignitary.constructor = Dignitary;
var d1 = new Dignitary("Jane", "Bimbo");
console.log(d1.firstName); // THIS IS COMING OUT UNDEFINED, WHAT AM I DOING WRONG?