getify / You-Dont-Know-JS

A book series on JavaScript. @YDKJS on twitter.
Other
178.87k stars 33.44k forks source link

Editorial Review, Scope & Closures, Appendix A #1632

Closed simonstl closed 4 years ago

simonstl commented 4 years ago

Editorial review, not a searchable issue.

Edition: (1st or 2nd) 2nd

Book Title: Scope & Closures

Chapter: Appendix A

General

I love having an appendix for all the weird tricky bits that are too long for notes or sidebars but don't fit smoothly into the primary flow of the book. Each section seems to flow fairly happily.

The main concern I had while reading it is that it's fairly easy to get lost. Partly it's that GitHub's layout doesn't emphasize navigation. (I turned to the Raw view for a clearer picture.) Headers are different sizes, slightly, but it's not that dramatic and you can only see one window of content at a time rather than a spread.

However, lots of people will be reading this under those kinds of circumstances. Since it's an appendix, and has neat clusters of parts, I'm thinking that a bit of redundancy might help readers to see what's coming and know when they can enjoy that "I've finished that" feeling. (Or at least know what's left to come.)

To do this, I'd suggest adding a list to the end of each section intro and maybe to the title intro. It could be a sentence, or it could be a bulleted list. (In appendix-land, I'd lean toward bullets.)

For example, for implied scope, the current one-sentence section intro might change to:

Scopes are sometimes created in non-obvious places. In practice, these implied scopes don't often impact your program behavior, but it's still useful to know they're happening. To minimize surprises, you're going to want to be aware of:

  • Parameter scope
  • Function name scope
  • Scope variations between anonymous and named functions
  • Arrow function scope, and
  • IIFE scope details.

Then something similar under The case for var. Seem workable?

Also, I like the constantly Confused headline. O'Reilly didn't support code formatting in headlines, so there are new opportunities here.

[Appendix B had no issues.]