Created
February 2, 2012 22:30
-
-
Save Diullei/1726205 to your computer and use it in GitHub Desktop.
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
(function(exports){ | |
function Carro(marca){ | |
this.marca = marca; | |
} | |
Carro.prototype.Km = 0; | |
Carro.prototype.andar = function(){ | |
console.log(textoFormatado.call(this)); | |
} | |
// este é um método privado | |
function textoFormatado(){ | |
return 'andando a ' + this.Km + 'km/h'; | |
} | |
exports.Carro = Carro; | |
})(this); | |
var camaro = new Carro('camaro'); | |
camaro.Km = 3; | |
camaro.andar(); | |
//=> andando a 3km/h |
This is very well written, best code I've ever seen
😕 😒
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow!! This is incredible!! Even 10 years ago you were a genius!