I have the following functions which define an inheritance chain.
function Person(name,age) {
this.name = name;
this.age = age;
}
Person.prototype.dance = function () {
console.log("Person is dancing");
};
var Programmer = function (name, age, skills)
{
Programmer.prototype = new Person(name, age);;
this.skills = skills;
};
Programmer.prototype.talkShit = function () {
console.log("The programmer " + this.name+ " is talking shit....");
};
and I try to call dance() method on a programmer object
var programmerX = new Programmer("Pro A", 30, "Talking crap");
programmerX.dance();
However, an error happened saying that dance() is undefined. I'm just wondering why? What's wrong?