From 5796a2ecb6d81ae447cc7179c01967bbfbe451e3 Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Sun, 21 Aug 2016 18:28:55 -0400 Subject: [PATCH] inheritance --- javascript.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/javascript.md b/javascript.md index b21ce91..db9d55a 100644 --- a/javascript.md +++ b/javascript.md @@ -342,3 +342,19 @@ var Person = function(){ Person.genders = ['male', 'female']; 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); +```