You Don't Know JS: Scope & Closures
Publisher: O'Reilly Media
Final Release Date: March 2014
Pages: 98

No matter how much experience you have with JavaScript, odds are you don’t fully understand the language. 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.

  • Learn about scope, a set of rules to help JavaScript engines locate variables in your code
  • Go deeper into nested scope, a series of containers for variables and functions
  • Explore function- and block-based scope, “hoisting”, and the patterns and benefits of scope-based hiding
  • Discover how to use closures for synchronous and asynchronous tasks, including the creation of JavaScript libraries
Product Details
About the Author
Colophon
Recommended for You
Customer Reviews

REVIEW SNAPSHOT®

by PowerReviews
oreillyYou Don't Know JS: Scope & Closures
 
4.3

(based on 19 reviews)

Ratings Distribution

  • 5 Stars

     

    (10)

  • 4 Stars

     

    (7)

  • 3 Stars

     

    (0)

  • 2 Stars

     

    (2)

  • 1 Stars

     

    (0)

89%

of respondents would recommend this to a friend.

Pros

  • Concise (15)
  • Easy to understand (15)
  • Helpful examples (14)
  • Accurate (13)
  • Well-written (13)

Cons

    Best Uses

    • Intermediate (14)
    • Novice (7)
    • Expert (6)
    • Student (5)
      • Reviewer Profile:
      • Developer (17)

    Reviewed by 19 customers

    Sort by

    Displaying reviews 1-10

    Back to top

    Previous | Next »

     
    4.0

    Good stuff - other Good Stuff

    By The Gayngler

    from New York, NY

    About Me Developer

    Verified Reviewer

    Pros

    • Accurate

    Cons

    • Not comprehensive enough
    • Too concise

    Best Uses

    • Expert

    Comments about oreilly You Don't Know JS: Scope & Closures:

    While this book attempts to demystify javascript scope and closures for javascript developers, it makes the topic mildly less mysterious. After reading this book, I think the explanation of both topics feels unfinished. I may go and re-read this book again. It is like The Good Parts without the immediately good even if controversial ideas in it.

    The author rather than try to fit in a full discussion on scope and closures elects to put additional information into an appendix which takes the reader away from very relevant and related questions that would likely further the readers understanding of the subject matter without having to skip all over the place. Usually, I tend to think of an appendix as off topic, related and useful information rather than a way to artificially keep the chapters short.

    LHS/RHS scope explanation feels out of place being located in the first few chapters of this book. (Note: On some level I understand the logic of it being here.) Somehow I feel like its a complex theoretical topic being thrown at you right away before you have a solid context. The author probably could be more successful with explaining LHS/RHS scope by starting with day to day scoping problems developers have with their code now. Instead it comes off as too theoretical too fast and if you are not already well versed on compiler theory you can get lost right at the beginning of the book.

    The question becomes are we trying to explain scope to developers who do not understand scope or are we trying to sound smart to developers who probably already understand scope.

    The other thing I think is lacking with this book's explanation of scope is this and passing scope around and executing functions in a scope outside of their own. Giving a full and in depth explanation if this is immediately useful in solving problems developers have everyday.

    Lastly, the information on closures really only lasts for a chapter and then its really just a definition and showing off some common javascript patterns that closures rather than a full explanation of closures.

    Ive read other reviews claiming the length is a plus but I feel like I would have liked those 20 pages they shaved off this book back. My review comes off as negative despite my 3.75 star review because I strongly feel like it could have been a 5 star book. There is great explanations in this book minus other great explanations that were left out of this book.

    (1 of 1 customers found this review helpful)

     
    4.0

    A very focused and consice book, but...

    By NCA

    from France

    About Me Developer

    Verified Reviewer

    Pros

    • Accurate
    • Concise

    Cons

      Best Uses

      • Novice
      • Student

      Comments about oreilly You Don't Know JS: Scope & Closures:

      The "You don't known JS" collection aims at uncovering lesser known features of JavaScript programming paradigms. In that respect this book is a complete success the style is concise and the author always stays on topic.

      But in my opinion, there is a particular topic, tightly linked with "Scope and Closures" that has been left out and this has been a big disappointment to me.

      Nowhere is it talked about how JS implementations manage memory. As a matter of fact, if "Scope and closures" are a formidable tool, they really are the tricky part of the language. They let you build ever growing and complex memory graphs that are hard to get rid of (or hard to understand how they are managed). And as more and more JS apps are being written, I think it is a concern. By apps I mean programs that sits on the user's desktop, or on a backend server, and are used all work day long, without being reset or restarted. The tools are presented here, but there effect are not described in an explicit enough fashion for my taste. But maybe was I expecting too much of this little book ? And I know I am biased, having done lots of development in C. Yet garbage collection has its limit and making sure you understand what is going under the hood cannot hurt.

      Still, having seen in the workplace how little of javascript many developers know, this book is still of great value. Especially for developers new to JavaScript: it will let them learn things right from the get go, instead of having them to guess and learn things the hard way.

      (1 of 1 customers found this review helpful)

       
      4.0

      Demythologizing Closures

      By ellmo

      from Poznań, Poland

      About Me Developer

      Verified Buyer

      Pros

      • Accurate
      • Concise
      • Easy to understand
      • Helpful examples

      Cons

      • Unnecessary References

      Best Uses

      • Intermediate

      Comments about oreilly You Don't Know JS: Scope & Closures:

      I bought this book for the sole purpose of finally trying to understand what exactly the mythical JavaScript closures are and what their relation is to scopes.
      I can't tell you how many times I've tried to grasp this concept with various online materials – but there always was something: either too few examples and too much theory, or just the opposite.

      At first I was disappointed with the low page count as I was expecting a thorough JavaScript programming manual. I then realized this small book (a booklet even) tackles only with the specified problem and does it extremely well, thanks to thought-out structure an extensive introduction to what scopes are – exactly what I needed.

      The only drawback (albeit minor) are the references and intercalations, which I sometimes found unnecessary.

      (1 of 1 customers found this review helpful)

       
      5.0

      By the end you'll see truth in the title

      By Mike

      from Canada

      About Me Developer

      Verified Reviewer

      Pros

      • Accurate
      • Concise
      • Easy to understand
      • Helpful examples
      • Well-written

      Cons

        Best Uses

        • Expert
        • Intermediate
        • Novice
        • Student

        Comments about oreilly You Don't Know JS: Scope & Closures:

        This book is not about linting, code style, why you should 'use strict' or how to best neuter parenthesis from your IIFEs.

        Despite having many years of front-end JavaScript experience and a few popular npms under my belt, this book has deepened my understanding and appreciation for JavaScript at a low level.

        Clear examples truly destined for developers from beginner (building a good foundation) to expert (back-filling gaps).

        I recommend this book especially to those who came to JavaScript from either a long career in another paradigm, or who came to programming without a background in foundational computer science.

        (1 of 2 customers found this review helpful)

         
        5.0

        Great Book. Up to the point

        By Vlad Bezden

        from Medford, NJ

        About Me Developer

        Verified Buyer

        Pros

        • Accurate
        • Concise
        • Easy to understand
        • Helpful examples
        • Well-written

        Cons

          Best Uses

          • Intermediate
          • Novice

          Comments about oreilly You Don't Know JS: Scope & Closures:

          I really like this book. It explains in great details two sections, scope and closures. I got a lot from this book. After reading this book I learned about JS hoisting, scope, closure and tips and tricks that one can have in JavaScript.

          (1 of 1 customers found this review helpful)

           
          4.0

          Good overview of variable scope

          By Arnold

          from Minneapolis, MN

          About Me Developer

          Verified Buyer

          Pros

          • Easy to understand
          • Helpful examples

          Cons

            Best Uses

            • Intermediate
            • Novice

            Comments about oreilly You Don't Know JS: Scope & Closures:

            I haven't read the section on closures yet, but the sections on variable scope were very well written and the examples helped to re-enforce the text.

            This book isn't intended to teach Javascript, but only to explore two important areas of using Javascript. In that, it meets expectations.

            (0 of 1 customers found this review helpful)

             
            4.0

            Read it if you care about your JS code

            By rsoares

            from Faro, Portugal

            About Me Developer

            Verified Buyer

            Pros

            • Concise
            • Easy to understand
            • Well-written

            Cons

              Best Uses

              • Expert
              • Intermediate

              Comments about oreilly You Don't Know JS: Scope & Closures:

              It has accurate and well explained details about he inner works of the language. Really helpful stuff.

               
              4.0

              Excellent short book

              By Alastair

              from London UK

              About Me Developer

              Verified Buyer

              Pros

              • Concise
              • Helpful examples
              • Well-written

              Cons

                Best Uses

                • Intermediate
                • Novice
                • Student

                Comments about oreilly You Don't Know JS: Scope & Closures:

                This is a very short book but describes the subject very well, including the (sometimes) hazy subject of "closures". Before getting to that though, it goes over "scope" and how the JS code ends up being parsed and executed. This includes how variable "declaration" and "assignment" is seen and handled by the various components of the JS "engine". Overall, well worth a read.

                (1 of 4 customers found this review helpful)

                 
                2.0

                Not very helpful

                By hmqcnoesy

                from Utah

                About Me Developer

                Verified Buyer

                Pros

                  Cons

                    Best Uses

                      Comments about oreilly You Don't Know JS: Scope & Closures:

                      This book tries to be "cute" in its explanations rather than giving straight talk about JavaScript scope and closures. I would recommend other books that contain just a chapter or small section explaining these concepts, such as Wrox Professional JavaScript for Web Developers by Nickolas Zakas.

                      (1 of 4 customers found this review helpful)

                       
                      2.0

                      single, simple thought for who?

                      By Claude in Washingon

                      from Washington state

                      About Me Developer

                      Verified Buyer

                      Pros

                      • Easy to understand
                      • Well-written

                      Cons

                      • Not comprehensive enough

                      Best Uses

                      • Student

                      Comments about oreilly You Don't Know JS: Scope & Closures:

                      This resource has an audience, but I'm not sure what it might be. It describes a single, simple thought that could have been done in a paragraph or two. If it takes more than that, then the users need to learn a little more JS first.

                      Displaying reviews 1-10

                      Back to top

                      Previous | Next »

                       
                      Buy 2 Get 1 Free Free Shipping Guarantee
                      Buying Options
                      Immediate Access - Go Digital what's this?
                      Ebook: $16.99
                      Formats:  DAISY, ePub, Mobi, PDF
                      Print & Ebook: $21.99
                      Print: $19.99