-
-
Save dutradotdev/b3dfa5cfcbcb514fe7b24eb7ab944ba7 to your computer and use it in GitHub Desktop.
Herança com métodos e constructor correto
This file contains 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
// agora a classe Ferrari extends Veiculo | |
Ferrari.prototype = Object.create(Veiculo.prototype); | |
// porém agora o constructor de Ferrari.prototype é igual | |
// ao de Veiculo.prototype... Precisamos resolver isso. | |
Ferrari.prototype.constructor = Ferrari; | |
let ff = new Ferrari(); | |
ff.acelerar() // works!! | |
Ferrari.prototype.constructor // Ferrari |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment