-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Description
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.
learn-nodejs-hard-way/chapters/ch04.0-logtar-our-logging-library.md
Lines 340 to 354 in 33b587c
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. |
Metadata
Metadata
Assignees
Labels
No labels