diff --git a/text/background/javascript.md b/text/background/javascript.md index 69f6849..0dfa56a 100644 --- a/text/background/javascript.md +++ b/text/background/javascript.md @@ -90,7 +90,7 @@ class Dog extends Animal { `Dog` is a subclass of `Animal`. `this.constructor.name` is the name of the class (`'Dog'` if `new Dog()` or `'Animal'` if `new Animal()`). In its constructor, it calls the superclass’s constructor (`super(name)`) and then logs. So now if we do: ```js -const graphy = new Dog() +const graphy = new Dog('Graphy') console.log(graphy.name) graphy.speak() ``` @@ -110,11 +110,16 @@ A subclass can override a superclass’s method or define new methods: class Dog extends Animal { constructor(name) { super(name) + console.log('Subspecies: Canis lupus familiaris.') } speak() { console.log(`${this.name} barks.`) } + + sit() { + console.log(`${this.name} sits.`) + } } const loren = new Animal('Loren')