inheritance

master
Matt Huntington 9 years ago
parent 9c1821e732
commit 5796a2ecb6

@ -342,3 +342,19 @@ var Person = function(){
Person.genders = ['male', 'female']; Person.genders = ['male', 'female'];
console.log(Person.genders); console.log(Person.genders);
``` ```
We can have a "class" inherit from another class, using the `.call` static method of a function
```javascript
var Car = function(){
this.wheels = 4;
}
var Humvee = function(){
Car.call(this);
this.numAmericanFlags = 4;
}
var murica = new Humvee();
console.log(murica);
```

Loading…
Cancel
Save