I have my master object:
var Person = function() {
this.canTalk = true;
}
Method I want all sub-objects to inherit:
Person.prototype.greet = function() {
if( this.canTalk ) {
console.log( 'Hi, I am ' + this.name );
}
}
Sub-object that inherits from Employee
var Employee = function( name, title) {
Person.call( this );
this.name = name;
this.title = title;
}
Instantiation:
var robert = new Employee( "Robert Rocha", "Software Developer" );
robert.greet();
greet()
gets the error: Uncaught TypeError: robert.greet is not a function
What am I doing wrong?