Created
          October 10, 2011 17:15 
        
      - 
      
 - 
        
Save carlosvillu/1275826 to your computer and use it in GitHub Desktop.  
    Como crear clases y herencias en JS
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var Forma = function(){}; | |
| Forma.prototype = { | |
| getArea: function() | |
| { | |
| console.log('Get Area from Forma'); | |
| } | |
| }; | |
| var Cuadrado = function() | |
| { | |
| var __super__ = Forma; | |
| __super__.apply(this); | |
| __super__ = null; | |
| }; | |
| Cuadrado.prototype = new Forma(); | |
| Cuadrado.prototype = { | |
| getArea: function() | |
| { | |
| console.log('Get Area from Cuadrado'); | |
| } | |
| }; | |
| var Circulo = function() | |
| { | |
| var __super__ = Forma; | |
| __super__.apply(this); | |
| __super__ = null; | |
| }; | |
| Circulo.prototype = new Forma(); | |
| Circulo.prototype = { | |
| getArea: function() | |
| { | |
| console.log('Get Area from Circulo'); | |
| } | |
| }; | |
| var Triangulo = function() | |
| { | |
| var __super__ = Forma; | |
| __super__.apply(this); | |
| __super__ = null; | |
| }; | |
| Triangulo.prototype = new Forma(); | |
| Triangulo.prototype = { | |
| getArea: function() | |
| { | |
| console.log('Get Area from Triangulo'); | |
| } | |
| }; | |
| (new Forma()).getArea(); | |
| (new Cuadrado()).getArea(); | |
| (new Circulo()).getArea(); | |
| (new Triangulo()).getArea(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment