Creando objetos javascript desde diferentes archivos.
He intentado hacer javascript desde hace algún tiempo, pero quiero que esté "orientado a objetos", así que estoy tratando de crear diferentes clases de javascript en diferentes archivos e intentar crear un objeto y llamar a sus métodos en un archivo diferente Funciona, pero no parece funcionar.
Esto es lo que tengo hasta ahora:
persona.jsfunction Person(name, age, gender)
{
this.age = age;
this.name = name;
this.gender = gender;
this.job;
this.setJob = function(job)
{
this.job = job;
}
this.getAge = function()
{
return this.age;
}
this.getName = function()
{
return this.name;
}
this.getGender = function()
{
return this.gender;
}
}
Job.jsfunction Job(title)
{
this.title = title;
this.description;
this.setDescription = function(description)
{
this.description = description;
}
}
main.jsfunction main()
{
var employee = new Person("Richard", 23, male);
document.getElementById("mainBody").innerHTML = employee.getName();
}
index.html<!DOCTYPE HTML>
<HTML>
<head>
<title>javascript test</title>
<script src="main.js" type="javascript"></script>
</head>
<body>
<p id="mainBody"></p>
</body>
</HTML>
Cualquier ayuda o consejo sería muy apreciado.
Muchas gracias
EDITAR: Muchas gracias por todas las respuestas y sugerencias, sin embargo, he incluido todos mis archivos javascript y todavía no funciona ...