Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some missing javascript in examples #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion text/background/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```
Expand All @@ -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')
Expand Down