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