//Now Lets do some Inheritance
//First create a basic type: Person
function Person(firstName, lastName, birthDate)
{
this.FirstName = firstName;
this.LastName = lastName;
this.BirthDate = birthDate;
}
//Now we can use this type:
var myPerson = new Person("Steve", "Miller", "06.20.1978");
var myPersonFirstName = myPerson.FirstName;
var myPersonLastName = myPerson.LastName;
var myPersonBirthDate = myPerson.BirthDate;
//Now lets create a new type: Employee
//An Employee is a person so it can inhertit its propertys
function Employee(firstName, lastName, birthDate, position, employeeID)
{
//Inherit from Person
Person.call(firstName, lastName, birthDate);
//But we need new propertys that person does not contain
this.Position = position;
this.EmployeeID = emloyeeID;
}
//Now lets create a new Employee
var myEmployee = new Employee("Steve", "Miller", "06.20.1978", "Boss", 1);
//Employee hast every property of a Person:
var myEmloyeeFirstName = myEmployee.FirstName;
var myEmployeeLastname = myEmployee.LastName;
var myEmployeeBirthDate = myEmployee.BirthDate;
//And Also its own propertys
var myEmloyee.Position = myEmployee.Position;
var myEmployeeID = myEmployee.EmployeeID;