Skip to content

Instantly share code, notes, and snippets.

@Diullei
Created February 2, 2012 22:30
Show Gist options
  • Save Diullei/1726205 to your computer and use it in GitHub Desktop.
Save Diullei/1726205 to your computer and use it in GitHub Desktop.
(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
@Telefragged
Copy link

Wow!! This is incredible!! Even 10 years ago you were a genius!

@iffanh
Copy link

iffanh commented Jul 15, 2021

This is very well written, best code I've ever seen

@Diullei
Copy link
Author

Diullei commented Feb 8, 2022

😕 😒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment