Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


This concise yet in-depth guide takes you inside scope and closures, two core concepts you need to know to become a more efficient and effective JavaScript programmer. You’ll learn how and why they work, and how an understanding of closures can be a powerful part of your development skillset. Like other books in the "You Don’t Know JS" series, Scope and Closures dives into trickier parts of the language that many JavaScript programmers simply avoid. Armed with this knowledge, you can achieve true JavaScript mastery.

Subscriber Reviews

Average Rating: 4.5 out of 5 rating Based on 4 Ratings

"Best explanation of scope and closure for JavaScript" - by Pawan on 05-APR-2014
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
If you're like most people who've stumbled into JavaScript not as their first programming language but as a necessity towards developing functional and interactive front-ends after primarily working on the middleware side, then this book is a must read. I am still amazed at so many people go through with delivering JavaScript based work without fully understanding the concepts behind lexical scoping, difference between function expression and declaration and more recently, closures.  This book opened those doors for me.

I think no JavaScript enthusiast or Guru will be complete without the full understanding of these concepts in JavaScript. Read this book to get a handle on the same concepts.

I am starting to like the 'You don't know JS' series and am eagerly awaiting the next book on 'this and prototypes'.

Report as Inappropriate

"Nice Read" - by Anonymous on 20-MAR-2014
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
Starting two chapters made me feel as if this book is a bible, but I was mostly eyeing on the concept of closure. The topic of Scope is explained in a beautiful fashion. For some one who is new to java script world, this book can bring java script enlightenment.

I was hoping of some grammatical explanation of how the ref variables within the lexical scope (for closure) are arranged in a stack and how the values are retrieved during closure.
Overall a nice read.

Report as Inappropriate


The publisher has provided additional content related to this title.


Visit the catalog page for Scope and Closures

  • Catalog Page

Visit the errata page for Scope and Closures

  • Errata

Download the supplemental electronic content for Scope and Closures

  • Supplemental Content