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 22 reviews)

Ratings Distribution

  • 5 Stars

     

    (11)

  • 4 Stars

     

    (9)

  • 3 Stars

     

    (0)

  • 2 Stars

     

    (2)

  • 1 Stars

     

    (0)

91%

of respondents would recommend this to a friend.

Pros

  • Easy to understand (18)
  • Helpful examples (17)
  • Concise (16)
  • Well-written (16)
  • Accurate (15)

Cons

    Best Uses

    • Intermediate (17)
    • Novice (10)
    • Expert (7)
    • Student (7)
      • Reviewer Profile:
      • Developer (20)

    Reviewed by 22 customers

    Sort by

    Displaying reviews 1-10

    Back to top

    Previous | Next »

     
    5.0

    Great book overall

    By Jas

    from Southern California

    About Me Developer

    Verified Buyer

    Pros

    • Easy to understand
    • Helpful examples
    • Well-written

    Cons

      Best Uses

      • Intermediate
      • Novice
      • Student

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

      I really enjoyed how this book was written. What I like best is that he's focusing on small chunks of the language that have typically caused huge amounts of confusion for new JavaScript developers rather than trying to cram in a whole overview of the language.
      Its a quick read and because of that I recommend it to just about everyone even if you think you have a pretty good handle on Scope and Closures.

      (0 of 1 customers found this review helpful)

       
      4.0

      Concepts you don't know you already use

      By Ken H

      from Australia

      About Me Developer

      Verified Reviewer

      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:

        Javascript has a number of features that can seem almost mystical to some developers, including the two concepts covered here, but they really aren't as elusive as some might think.

        This book assists in showing just how intrinsic scopes and closures are to the way we already code whether you know it or not, and will provide a good basis for recognizing how and when you use them, and allow you to take it a step further to openly and knowingly leverage the benefits they provide.

        While many of the code examples are contrived and have no real world usage, they do quickly and concisely prove the concepts they are aiming to prove and thus can't really be faulted for that.

        Unfortunately there is only a minimal coverage of Javascript's "this" despite that it is intrinsically tied to scope, which does make it feel like there is something missing (however "this" is covered in the next book in the series which also covers object prototypes, and may be just as appropriately placed there as it would have been in this book).

         
        4.0

        Good book even if you know JS

        By Mark T

        from Chicago, IL

        About Me Developer

        Verified Buyer

        Pros

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

        Cons

        • Short

        Best Uses

        • Expert
        • Intermediate
        • Novice
        • Student

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

        The book provided some great clarification on the way JS works and more insight on Scopes and Closures.

        I would have liked a little more depth around some of the more complex applications and uses of scopes, but overall this book is a great, quick read with a lot of useful information.

        Definitely recommended.

         
        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 2 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.

          (2 of 3 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 3 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.

                  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