You Don't Know JS Yet: Scope & Closures
You Don't Know JS Yet: Scope & Closures
$23.95
Minimum price
$23.95
Suggested price
You Don't Know JS Yet: Scope & Closures

Last updated on 2020-04-27

About the Book

The worldwide best selling You Don't Know JS book series is back for a 2nd edition: You Don't Know JS Yet. All 6 books are brand new, rewritten to cover all sides of JS for 2020 and beyond. You'll still get in-depth coverage of the core language, applied in useful code organization patterns for your programs. And of course, through Kyle's unique perspective and conversational tone, explore passionate, reasoned debate of the most common questions developers face.

Scope & Closures, the second book in the new edition series, dives deep into how and why to organize variables into different buckets of scope, limiting scope over-exposure and improving code maintainability. On top of lexical scope, closure empowers functions with memory, preserving variables across calls. Modules leverage scope and closures to encapsulate data and behavior.

In Scope & Closures, you'll dig into:

  • Nesting lexical scopes with functions and blocks, to limit scope exposure of variables
  • Functions remembering variables through closure
  • Modules, one of the most important code organization patterns in programming

~~~~

Frontend Masters is the premier sponsor of the 2nd edition of the *You Don't Know JS Yet* book series.

Frontend Masters helps you advance your skills with in-depth, modern front-end engineering courses, the highest quality video content available anywhere on the web. With over 150 courses to choose from, the expert content you need to take your development to the next level is here, so get started by joining today!

Among the amazing courses in the Frontend Masters library, Kyle's courses are the perfect companion materials to this book series. Check them all out, including these few specifically:

About the Author

Kyle Simpson
Kyle Simpson

Kyle Simpson is an evangelist of the open web, passionate about all things JavaScript. He's an author, trainer, speaker, and OSS contributor.

Table of Contents

  • Foreword
  • Preface
    • The Parts
    • The Title?
    • The Mission
    • The Path
  • Chapter 1: What’s the Scope?
    • About This Book
    • Compiled vs. Interpreted
    • Compiling Code
    • Compiler Speak
    • Cheating: Runtime Scope Modifications
    • Lexical Scope
  • Chapter 2: Illustrating Lexical Scope
    • Marbles, and Buckets, and Bubbles… Oh My!
    • A Conversation Among Friends
    • Nested Scope
    • Continue the Conversation
  • Chapter 3: The Scope Chain
    • “Lookup” Is (Mostly) Conceptual
    • Shadowing
    • Function Name Scope
    • Arrow Functions
    • Backing Out
  • Chapter 4: Around the Global Scope
    • Why Global Scope?
    • Where Exactly is this Global Scope?
    • Global This
    • Globally Aware
  • Chapter 5: The (Not So) Secret Lifecycle of Variables
    • When Can I Use a Variable?
    • Hoisting: Yet Another Metaphor
    • Re-declaration?
    • Uninitialized Variables (aka, TDZ)
    • Finally Initialized
  • Chapter 6: Limiting Scope Exposure
    • Least Exposure
    • Hiding in Plain (Function) Scope
    • Scoping with Blocks
    • Function Declarations in Blocks (FiB)
    • Blocked Over
  • Chapter 7: Using Closures
    • See the Closure
    • The Closure Lifecycle and Garbage Collection (GC)
    • An Alternative Perspective
    • Why Closure?
    • Closer to Closure
  • Chapter 8: The Module Pattern
    • Encapsulation and Least Exposure (POLE)
    • What Is a Module?
    • Node CommonJS Modules
    • Modern ES Modules (ESM)
    • Exit Scope
  • Appendix A: Exploring Further
    • Implied Scopes
    • Anonymous vs. Named Functions
    • Hoisting: Functions and Variables
    • The Case for var
    • What’s the Deal with TDZ?
    • Are Synchronous Callbacks Still Closures?
    • Classic Module Variations
  • Appendix B: Practice
    • Buckets of Marbles
    • Closure (PART 1)
    • Closure (PART 2)
    • Closure (PART 3)
    • Modules
    • Suggested Solutions
  • Notes

About the Publisher

This book is published on Leanpub by GetiPub

GetiPub helps aspiring authors with assisted self-publishing.

Authors have earned$9,116,246writing, publishing and selling on Leanpub,
earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub