UNPKG

400 BJavaScriptView Raw
1/*Teste*/
2var vehicle = {
3 init: function(carModel){
4 this.model = carModel;
5 },
6 getModel: function(){
7 console.log("Model:" +this.model);
8 }
9}
10
11function buildCar(model){
12 function Car(){}
13 Car.prototype=vehicle;
14 var carInstance = new Car();
15 carInstance.init(model);
16 return carInstance;
17}
18
19var fusca = buildCar("Fusca");
20var porsche = buildCar("Porsche");
21fusca.getModel();
22porsche.getModel();
\No newline at end of file