2 de Septiembre 2003

OO JavaScript

Si, aunque poca gente lo sepa, JavaScript soporta algo parecido a la programación orientada a objetos.

Se pueden hacer clases, implementar jerarquias e incluso polimorfismo.

function Employee () {
  this.name = "";
  this.dept = "general";
}
function Manager () {
  this.reports = [];
}
Manager.prototype = new Employee;

function WorkerBee () {
this.projects = [];
}
WorkerBee.prototype = new Employee;

extraido del mejor artículo que conozco (de Netscape):
Details of the Object Model

Posted by rido at 2 de Septiembre 2003 01:13
Comments

tal como el java mismo ;)

Posted by: mikel on 3 de Septiembre 2003 01:47
Post a comment