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

few suggestions #53

Open
wants to merge 1 commit into
base: main
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
4 changes: 3 additions & 1 deletion book-content/chapters/12-the-weird-parts.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ class Song {
}
```

Stress here that song is a **runtime construct** that actually executes in JavaScript, and could, with different functions, be passed around. And is ALSO a type, as you show below

We can use the `Song` class as a type, for instance to type a function's parameter:

```tsx
Expand Down Expand Up @@ -655,7 +657,7 @@ When we call the `sellAlbum` function, it will increment the `sales` property an
album.sellAlbum(); // logs "Solid Air has sold 40001 copies."
```

This works because when declaring a function with the `function` keyword, `this` will always refer to the object that the function is a part of. Even when the function implementation is written outside of the object, `this` will still refer to the object when the function is called:
This works because when declaring a function with the `function` keyword (or method syntax, ie `sellAlbum() { }`), `this` will always refer to the object that the function is a part of. Even when the function implementation is written outside of the object, `this` will still refer to the object when the function is called (assuming it's called as `object.function()`):

```tsx
function sellAlbum() {
Expand Down