I am learning JavaScript and am little confused on how to create new JavaScript class based on an existing class and extend it.
I have a Person class which, I have created 2 instances from (John and Suzie). Now, I want to create another classe (Employee) based on Person with few more properties like Employee Number (and is it possibleto go back to John so that he inherits from Employee class).
This is what I have got:
var Person = function (name, age){
this.name = name || "UNKNOWN";
this.age= age || "UNKNOWN";
}
Person.prototype.sayHello = function() {
console.log("Hello, my name is " + this.name + " and I am " + this.age + " years old");
};
var john = new Person("John Smith",72);
var Suzie = new Person("Suzie Brown", 25);