Creo en nosotros. Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 /* INHERIT SAMPLE */2 3 var parent = function() {4  5  alert('Constructor padre');6  7  this.attribute1 = 'atributo del padre (publico)';8 }9 10 parent.prototype.method1 = function(arg1) {11  return 'result 1 - '+arg1;12 }13 14 parent.prototype.method2 = function(arg1) {15  return 'result 2 - '+arg1;16 }17 18 parent.prototype.method3 = function() {19  return 'soy un método del padre';20 }21 22 parent.prototype.extends = function(o) {23  24 }25 26 27 var child = function() {28  alert('Constructor hijo');29 }30 31 // Herencia:32 child.prototype = new parent();33 34 child.prototype.method4 = function() {35  return 'soy un método del hijo';36 }37 38 39 40 var c = new parent();41 alert(c.method4());42 alert(c.method3());43 alert(c.attribute1);44 45 46 47 
Enlace
El enlace para compartir es: