Under the section "The Property (object attribute)" the code segment has two curious lines. I expect the first cancels out the latter, making the latter useless.
// in Person function
this.gender = gender;
// outer scope (gender will never be this value because it is overridden by the person constructor argument)
Person.prototype.gender = 'Person Gender';
Am I correct, or does the prototype.gender line have some other purpose than instantiating gender to a value that is immediately overridden by the passed in value (or undefined if no value is passed)?
It's ensuring a default value basically. If you instantiate a person without an argument and try to reference this.gender later, you'll throw a script error. This is just avoiding that.
A way I'd prefer might look like this:
function Person = function(gender) {
this.gender = gender || 'neuter' //the sauce that defines a fallback
}
This is not the case, because in the constructor person is being set to the argument. If the argument is not supplied (undefined), calling the instantiated object's gender property will result in undefined. [tested and confirmed]