Smipple is shutting down Nov 30, 2017. Some features are currently disabled.
Profile image for Klaus Kazlauskas klausmachado
The other function wasn't a smart thing to do... it was just like use
this.oi = new oi();

Now is really extending a javascript class
Language
JavaScript
Tags
class extend javascript method
Favorited By
Profile image for Klaus Kazlauskas

Real extending class

1 function oi() 2 { 3 this.metodo = 'algo assim'; 4 this.martelo = function() 5 { 6 return false; 7 } 8 } 9 10 function teste() 11 { 12 this.extender = function(funcao) 13 { 14 var extendido = eval("new " + funcao + "()"), 15 valorPropriedade = null; 16 for(var propriedade in extendido) 17 { 18 valorPropriedade = eval("extendido." + propriedade); 19 eval("this." + propriedade + " = valorPropriedade"); 20 } 21 } 22 } 23 24 var testando = new teste(); 25 26 testando.extender('oi'); 27 28 testando;

Comments