Goodreads helps you keep track of books you want to read.
Start by marking “You Don't Know JS: Scope and Closures (You Don't Know JS, #2)” as Want to Read:
You Don't Know JS: Scope and Closures (You Don't Know JS, #2)
Enlarge cover
Rate this book
Clear rating
Open Preview

You Don't Know JS: Scope and Closures

(You Don't Know JS #2)

4.56  ·  Rating details ·  1,455 ratings  ·  117 reviews
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 ...more
Paperback, 98 pages
Published March 24th 2014 by O'Reilly Media (first published January 1st 2014)
More Details... Edit Details

Friend Reviews

To see what your friends thought of this book, please sign up.

Reader Q&A

To ask other readers questions about You Don't Know JS, please sign up.

Be the first to ask a question about You Don't Know JS

Community Reviews

Showing 1-30
Average rating 4.56  · 
Rating details
 ·  1,455 ratings  ·  117 reviews


More filters
 | 
Sort order
Start your review of You Don't Know JS: Scope and Closures (You Don't Know JS, #2)
Sallar
Jun 24, 2015 rated it it was amazing
Does a programming book get better than this? I don't think so.
Ilya Ivanov
Sep 21, 2015 rated it it was amazing
Marvelous book. Kyle deserves every cent received at Kickstarter.

The book is so concise, that it seems like every word is brushed until it shines, revealing the underlying truth about JavaScript and it's key differences from other languages.

Topics covered: scope, different types of scope, modules, IFFE, hoisting, closures, polyfilling. Code samples are short, intention revealing and very informative.

I've been through two books in this series and very thrilled to dive deeper into next books.

...more
Dave Peticolas
Nov 22, 2015 rated it really liked it
What a great little book. This might be the first Javascript book I've managed to finish without having my eyes glaze over from the tedium. Modern technical books tend to lean far too much on how-to examples and not enough time on deeper explanations. This book focuses on one particular aspect of the language, scope rules and closures, and explains it in depth. The author understands how important well-crafted analogies and mental models are for achieving genuine understanding.
Temur Tchanukvadze
Oct 14, 2018 rated it it was amazing
Shelves: js
Recommended! It doesn't matter how good/bad JS developer you are. You need to fill your gaps and YDKJS is the best choice.
Irakli Iremashvili
Mar 08, 2019 rated it it was amazing
For most newcomers to Javascript (whether they know any other programming language or not), it's scope and closure behaviour may seem very strange. This book helps you understand this topic and become a better developer
Tiffany
Sep 11, 2018 rated it liked it
You can find a full review of this book at Tiffany R. White Blog.
Preeti Yadav
I'm reading the entire series and this book is a let down to its predecessor, at least to me. I expected to understand a bit more than what was offered in this part of the series. Most of the times, I was "What? What was that again?". I'll try to give it one more read and maybe get something more out of it.
Jarek
Oct 27, 2015 rated it it was amazing
Shelves: non-fiction
Excellent book, which describes the subject to its full extent.
Alex
Nov 12, 2018 rated it it was amazing
Shelves: tech, programming
Short, to the point, clearly explained, and written with a bit of humor. A delight to read.
Heba Atallah
Oct 13, 2017 rated it it was amazing
Shelves: javascript
That's what I'm calling the perfect book
Mark
Apr 04, 2018 rated it really liked it  ·  review of another edition
Not a bad deep dive into scope & closures. I picked up a good amount along the way. I'd definitely supplement this with YouTube videos to follow up.
Affan
Jul 25, 2015 rated it it was amazing
Shelves: programming
Awesome book. Helped me gain a better understanding of Scope and Closures and clear up some misconceptions! Before reading this book i actually thought JavaScript is an interpreted language but learned it is in fact a compiled language but its different from other compiled languages because compilation does not happen well in advance rather just milliseconds before execution. I also liked his definition of a closure, 'Closure is when a function is able to remember and access its lexical scope ...more
Prakash
Dec 03, 2017 rated it liked it
Perhaps not worthy of a stand-alone title. And don't really agree with all of the advices regarding let.

The author's advice is also contradictory in the spirit of the series which is to understand deeply and then use it correctly.

On the other hand, for let the recommended use is only for block scope and even then make it explicit with braces. Ahem, that's why you use the new keyword 'let'.

If your code breaks after replacing var with let, you weren't writing very clean code in the first place.
Dan
Jun 03, 2015 rated it it was amazing
I needed something to explain scopes and closures to a Junior Dev I've started working with and mentoring recently. The usual examples and code samples weren't clicking, and I began to realize that, even for me, those old stand-by's weren't what actually got me to grock closure. I had to use the module pattern extensively before I really understood the concept at an intuitive level.

This book fills in what I needed experience to understand. It is concise, it is accurate, it is clear. You can't
...more
Joshua Isaac
Mar 19, 2015 rated it it was amazing
Shelves: programming
This book was a nice refresher of things I already knew, as well as a tidy introduction to some new syntax in EC6. I appreciated his coverage of IIFEs because that's syntax I'm always very confused about. This book was explicit in its scope (hah!) - it really didn't touch on much else besides scopes and closures - but it also didn't shy away from telling you about powerful language functions just because they are not nice to think about.
Robson Castilho
Dec 15, 2016 rated it really liked it
Shelves: software
Concepts such as lexical scopes, function and block scopes, closures, module pattern, IIFE and hoisting are all well explained with simple code examples. At the start, a very good intro about Javascript compilation process, its compiler and engine.
Additionally, some new ES6 features are presented in conjuction with pollyfill solutions for block scopes.
A very good book for those who wants to understand how JS works!
Jeff Richardson
Jun 09, 2014 rated it it was amazing
While I already considered myself somewhat of an expert when it came to scope and closure, I've read and heard Crockford talk about them a lot over the years, and Zakas books have a wealth of information on scope and closures as well I feel this book provided a new light on them. I'm a better Client Side Engineer for having read this book.
Hưng Đặng
Sep 09, 2018 rated it really liked it
It is surprising that this good book is not too much beyond my comprehension of the language and my meager experience in the field is also a great help. Few things that I might need to go over again because I am still confused with them:

1. JS is compiled, it is not just interpreted

2. Tokenizing and lexing.

3. JS conpilation doens't work in a build step ahead of time like other language. So I guess it works in run time!

4. LHS cares about target of the assignment while RHS wants to know about the
...more
Md. Jamal Uddin
Sep 29, 2018 rated it really liked it
Shelves: computer-science
Engine: Hey Scope, I have an RHS reference for foo. Ever heard of it?

Scope: Why yes, I have. Compiler declared it just a second ago. He's a function. Here you go.

Engine: Great, thanks! OK, I'm executing foo.

Engine: Hey, Scope, I've got an LHS reference for a, ever heard of it?

Scope: Why yes, I have. Compiler declared it as a formal parameter to foo just recently. Here you go.

Engine: Helpful as always, Scope. Thanks again. Now, time to assign 2 to a.

Engine: Hey, Scope, sorry to bother you again.
...more
David
Sep 06, 2017 rated it it was amazing
Did you know JavaScript is actually a compiled language? You probably did not. This and many other mind-blowing discoveries is what you will find after reading this book.

I learned what I know about JavaScript the usual way: try something; see it failing; try something else; see it working, but not really understanding why; move on with life.

This book enlightens you with the inner workings of JavaScript, specifically with something you use at every single JavaScript snippet you write, scope. It
...more
Mark
Jul 16, 2017 rated it it was amazing  ·  review of another edition
Excellent coverage over these topics. One part I appreciated so much was that these topics are rarely covered well in any learning book, but are covered very well here, with reference to other ways for a more complete understanding. Kyle tells us about dynamic scoping and highlights the potential pitfalls of an area that is a mixture ("this" which in one context operates with lexical scope and in another case operates with dynamic scope). For me, the real attraction was a good understanding of ...more
Yanjia Li
Aug 06, 2018 rated it it was amazing
Another must read for Javascript developers who want to understand the mechanism behind the scene. Unlike Types & Grammar which somewhat looks tricky, the knowledge in this book could really help in work. This is one of the few books that explains what is closure and why it's called closure. To simply put, a closure close a scope. But maybe most of JS developers don't even understand lexical scope much, which prevent them from understanding closures more thoroughly. And the author caught ...more
Dawn Saquin
Jul 26, 2018 rated it really liked it
Great book that helped me understand a little more about function and block scoping, and how to point out closures. I also got a clearer picture on when to use the variable declarations let and const.
I still have a few uncertainties about using 'this' and arrow functions together, since Kyle says to avoid it and stick to one. I guess I'll know more about it in the next book in the series. : )

Overall, this book helps me think more like a JS programmer and to know that functions are powerful in
...more
Kevin Sweet
Aug 25, 2019 rated it it was ok
This installment in YDKJS focused too much on the parts of JS that you're probably not using anymore. Yes, var has a lot of idiosyncrasies. That's why we use const now, but the book spent two sentences offhandedly mentioning const.

JavaScript has a lot of baggage from its early days, but I would argue that learning the intricacies of how people used to write JavaScript isn't very useful today. Install ESLint, enable some recommended packages, and forget that it's possible to use those old
...more
Devin
May 13, 2018 rated it really liked it  ·  review of another edition
I've puzzled through enough JavaScript to develop an intuitive sense of scope and closure. But the temptation is to never give it much thought in the name of churning out code that works. The reality is that "What is Closure?" is an incredibly common interview question for almost any tech screen and it pays to develop a vocabulary for discussing it.

The additional study of how to leverage an understanding of closure in one's code is invaluable. And clearly about to lead into a long discussion of
...more
Julien Bérubé
Mar 06, 2019 rated it it was amazing
If you want a deep understanding of the underlying mechanism that makes javascript a powerful language - of if you just want to be able to debug those nasty closure bugs - this is THE book you need.
Cheap, and only 73 small pages full of diagram, so there is no excuses. This book have the highest value per page read.
If you're new to JavaScript, read "JavaScript: The Good Parts" first.
Jeremiah John
Sep 25, 2018 rated it it was amazing
I have heard it said that a JS developer's knowledge of scope practically determines their experience level.

This is the perfect book on scope; it is unsparing in its detail and thorough in edge cases.

If you've ever been in a code base touched by those who never heard the name "Crockford" then this is your book.
Jon Jones
Oct 21, 2019 rated it it was amazing
Scopes and closures we're one topic that always confused me around JS, even though I have read lots of blogs and online tutorials. this book goes into really good in-depth explanations and I finally understand and get how this complex subject works.

An essential read for all Javascript developers.
Bonkerstone
Oct 25, 2017 rated it really liked it
Learned a lot from this book, extremely good.

I rated it 4 stars because it would have been much more awesome if he went into Dynamic vs Lexical Scope a little deeper, it was a real struggle understanding that all on my own.
Arnab Das
Feb 01, 2019 rated it it was amazing
Absolutely brilliant! This book explains scope and closure using simple examples. Some of them contain good humor too. Got to know about the term "dynamic scoping" and its interesting behavior. Highly recommended for anyone facing hard time understanding the scope and closure of JS.
« previous 1 3 4 next »
There are no discussion topics on this book yet. Be the first to start one »

Readers also enjoyed

  • Eloquent JavaScript: A Modern Introduction to Programming
  • JavaScript: The Good Parts
  • JavaScript Patterns
  • HTML and CSS: Design and Build Websites
  • Secrets of the JavaScript Ninja
  • Refactoring UI
  • The Principles of Object-Oriented JavaScript
  • JavaScript: The Definitive Guide
  • Learning React: Functional Web Development with React and Redux
  • Clean Code: A Handbook of Agile Software Craftsmanship
  • JavaScript and jQuery: Interactive Front-End Web Development
  • The Road to learn React
  • Grokking Algorithms An Illustrated Guide For Programmers and Other Curious People
  • Design Patterns: Elements of Reusable Object-Oriented Software
  • The Pragmatic Programmer: From Journeyman to Master
  • Node.js Design Patterns
  • Learning How to Learn: How to Succeed in School Without Spending All Your Time Studying; A Guide for Kids and Teens
  • A Smarter Way to Learn JavaScript: The new approach that uses technology to cut your effort in half
See similar books…

Goodreads is hiring!

If you like books and love to build cool products, we may be looking for you.
Learn more »
212 followers
Kyle Simpson is an Open Web Evangelist from Austin, TX, who's passionate about all things JavaScript. He's an author, workshop trainer, tech speaker, and OSS contributor/leader.

Other books in the series

You Don't Know JS (6 books)
  • You Don't Know JS: Up & Going
  • You Don't Know JS: this & Object Prototypes
  • You Don't Know JS: Types & Grammar
  • You Don't Know JS: Async & Performance
  • You Don't Know JS: ES6 & Beyond
“Closure is when a function is able to remember and access its lexical scope even when that function is executing outside its lexical scope.” 4 likes
More quotes…