From c5cf998498d4331fedddad29ddf6904cf1c4e1b1 Mon Sep 17 00:00:00 2001 From: Adam Rackis Date: Wed, 31 Jul 2024 18:05:16 -0500 Subject: [PATCH] few suggestions --- book-content/chapters/12-the-weird-parts.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/book-content/chapters/12-the-weird-parts.md b/book-content/chapters/12-the-weird-parts.md index 0c980f7..5a3e367 100644 --- a/book-content/chapters/12-the-weird-parts.md +++ b/book-content/chapters/12-the-weird-parts.md @@ -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 @@ -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() {