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

Problem in Chapter 04.0, line 351 #62

Open
stefanos82 opened this issue Sep 24, 2024 · 0 comments
Open

Problem in Chapter 04.0, line 351 #62

stefanos82 opened this issue Sep 24, 2024 · 0 comments

Comments

@stefanos82
Copy link

I'm currently reading the PDF (nice work by the way!) and when I tested the code, line 351 worked which baffled me; after a couple of reads, I have realized I didn't have 'use strict'; at the very top of my file, which is not mentioned anywhere in the book.

Let's try to test this.
```js
new Logger("OK"); // throws error
new Logger(LogLevel.Debug); // works fine
new Logger(); // works fine
let logger = new Logger(LogLevel.Warn);
logger.level; // returns the `level` because of the getter `level()`
logger.#level; // throws error
logger.#level = LogLevel.Warn; // throws error
logger.level = 10; // throws error
```
Perfect! This all looks really good. We are confident that neither clients nor our own library's code will affect the internals of the library. Please note that only the `#level` member variable can be changed from within the class Logger's scope, which is exactly what we want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant