

Desertcart purchases this item on your behalf and handles shipping, customs, and support to Ireland.
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 Review: Excellent Book, Could Use Some Squirrels, Highly Recommended - This is an excellent book overall. I can use it to improve my understanding of JavaScript and thereby also improve own JavaScript code. I think what won me over to the book was reading some of the bits of how Javascript code compilation occurs, starting with tokenizing, and the "conversations" between Engine, Compiler and Scope. I realized I needed to read the book cover to cover. A few months after purchasing the book, I'm getting near the end of it, and thoroughly enjoying it. The book explains scope and closures in great detail, with example code that is repeatable (although if you want to use the 'let' verb within a script that will be executed by the Node.js v0.10.31 engine, you will need to do that in strict mode and use the --harmony flag.) I will need to re-read this book a few times over for the examples and discussion to really strike home, but I have had several moments already where the author helps me understand why my own application code is having trouble. For example, I'm having variable collisions and I'm not using function expressions and/or immediately invoked function expressions when I really should. This book is teaching me these things and showing me a better way to code. It is helping me to think like Compiler, Scope and Engine when I see my code. This must be the first technical book I've actually read that makes fleeting reference to Luke Skywalker. Maybe JavaScript really does need someone with a "warrior aiming for excellence" viewpoint in order to convince developers to master it? Resig and Bibeault, after all, recall the ways of the ninja. Well, if I were to compare myself to a warrior, it would have to be as a recruit in the most basic training camp. Even in this setting I can accomplish more with a close study of this book. I might even become a pretty good coder. For others, I'm sure they can rise to the ninja or even the Skywalker planes. In fact this book is so good that I ordered the other print book and pre-ordered all the titles which will be released in November for this series. Let us look at the ways this book could be improved: The author uses parenthetical (writing too much). For example: "We take an inner function (named timer)..." could just as easily be written without the parentheses: "We take an inner function named timer...". I personally find parenthetized text distracts me from the real point the author is trying to make. There are loads of "crow" icons in the book (meaning general notes), but no "squirrel" (to signify a tip or suggestion) or "lobster" (warning) icons. I'd love to see some squirrels! The reader has to decide when the author must be passing on a coding tip. Or perhaps he doesn't want to mess with that? There is no book index. There is no history of how the book was funded over Kickstarter, and I would love to know more about that. With that said, this book is worth every penny of my money and I expect the entire series will be, too. If you are a beginner at JavaScript, buy this book! Review: Well worth reading. - Excellent book. I have been working with Javascript for many years. But, could never really wrap my head around scope and closures. Can't say I have it fully mastered yet. But, thanks to this book I am miles ahead of where I was. Kyle Simpson has a talent for explaining things in a way that manage to get through. This is a book worth reading once a year as you develop so that you can dig deeper and deeper. I don't say this because you walk away from your first reading puzzled. Rather, for me anyway, I walked away from my first reading with a much clearer understanding. And from the second reading even more. Trouble is, in javascript there are many intertwined topics. After reading "Scope & Closures" I read Kyle's book on "This". That cleared up even more, so that rereading Scope & Closures elucidated further. The depths of javascript are not linear. So touching on certain topics from different angles is a good approach -- imo. And this book definitely gives you another perspective.
| Best Sellers Rank | #1,529,804 in Books ( See Top 100 in Books ) #276 in JavaScript Programming (Books) #2,185 in Software Development (Books) #2,876 in Computer Programming Languages |
| Customer Reviews | 4.7 out of 5 stars 495 Reviews |
R**N
Excellent Book, Could Use Some Squirrels, Highly Recommended
This is an excellent book overall. I can use it to improve my understanding of JavaScript and thereby also improve own JavaScript code. I think what won me over to the book was reading some of the bits of how Javascript code compilation occurs, starting with tokenizing, and the "conversations" between Engine, Compiler and Scope. I realized I needed to read the book cover to cover. A few months after purchasing the book, I'm getting near the end of it, and thoroughly enjoying it. The book explains scope and closures in great detail, with example code that is repeatable (although if you want to use the 'let' verb within a script that will be executed by the Node.js v0.10.31 engine, you will need to do that in strict mode and use the --harmony flag.) I will need to re-read this book a few times over for the examples and discussion to really strike home, but I have had several moments already where the author helps me understand why my own application code is having trouble. For example, I'm having variable collisions and I'm not using function expressions and/or immediately invoked function expressions when I really should. This book is teaching me these things and showing me a better way to code. It is helping me to think like Compiler, Scope and Engine when I see my code. This must be the first technical book I've actually read that makes fleeting reference to Luke Skywalker. Maybe JavaScript really does need someone with a "warrior aiming for excellence" viewpoint in order to convince developers to master it? Resig and Bibeault, after all, recall the ways of the ninja. Well, if I were to compare myself to a warrior, it would have to be as a recruit in the most basic training camp. Even in this setting I can accomplish more with a close study of this book. I might even become a pretty good coder. For others, I'm sure they can rise to the ninja or even the Skywalker planes. In fact this book is so good that I ordered the other print book and pre-ordered all the titles which will be released in November for this series. Let us look at the ways this book could be improved: The author uses parenthetical (writing too much). For example: "We take an inner function (named timer)..." could just as easily be written without the parentheses: "We take an inner function named timer...". I personally find parenthetized text distracts me from the real point the author is trying to make. There are loads of "crow" icons in the book (meaning general notes), but no "squirrel" (to signify a tip or suggestion) or "lobster" (warning) icons. I'd love to see some squirrels! The reader has to decide when the author must be passing on a coding tip. Or perhaps he doesn't want to mess with that? There is no book index. There is no history of how the book was funded over Kickstarter, and I would love to know more about that. With that said, this book is worth every penny of my money and I expect the entire series will be, too. If you are a beginner at JavaScript, buy this book!
C**N
Well worth reading.
Excellent book. I have been working with Javascript for many years. But, could never really wrap my head around scope and closures. Can't say I have it fully mastered yet. But, thanks to this book I am miles ahead of where I was. Kyle Simpson has a talent for explaining things in a way that manage to get through. This is a book worth reading once a year as you develop so that you can dig deeper and deeper. I don't say this because you walk away from your first reading puzzled. Rather, for me anyway, I walked away from my first reading with a much clearer understanding. And from the second reading even more. Trouble is, in javascript there are many intertwined topics. After reading "Scope & Closures" I read Kyle's book on "This". That cleared up even more, so that rereading Scope & Closures elucidated further. The depths of javascript are not linear. So touching on certain topics from different angles is a good approach -- imo. And this book definitely gives you another perspective.
W**R
Polarized Opinions
This book will for sure suffer from polarized opinions, but I have no doubt it will become one of the most influential and popular JavaScript books. I came from a Java/Scala background. There are many books that discuss the deep features of those languages and how they are implemented. Through reading them, you get a very nice picture of those languages. It is not the same about JavaScript. Here are some JavaScript books I've read: Professional JavaScript for Web Developers by Nicholas C. Zakas Secrets of the JavaScript Ninja by John Resig and Bear Bibeault Object-Oriented JavaScript, 2nd Edition by Stoyan Stefanov and Kumar Chetan Sharma Granted those books are highly praised in the JS community, they failed to answer one big question: what is JavaScript? What's the functionality of JavaScript? Kyle Simpson addressed this concern open and clear in his preface that he aimed to address those questions. So for me, this is the perfect book. I am now half way through this book, and it is a very well-written book. It's short, but concise. Some people might think the short length of this book should be criticized, but I believe it's a great feature because you will have time to finish the book before the next book come out. It has a clear presentation of hard-to-understand JavaScript concepts along with occasionally visual aids. However, it is not a book for beginners. Beginners might get confused because of the pedantic nature of this book. Also, for some people, who wants more straight-forward explanation and I imagine there are many of them out there, it is unworthy of buying. This book favors jargons, and might have gone too far with them. I don't consider it a problem, but I can see how it might irritate some readers. In chapter 1, author went in a huge length letting us know the difference between LHS and RHS (two types of lookup methods), and carry them through the entire chapter. Is it important? Not really. It seems like as long as you employ the "strict mode", two methods are completely indistinguishable. I'm a graduate student and I'll take a class on compiler construction soon or later, so this little mental exercise is enjoyable for me, but again, some people might ask why presenting them if they barely makes a difference. In chapter 2, author talked about lexical scope, but almost half of the chapter is used to discuss two functions "eval()" and "with()" and then warned you to never use them. I know it sounds like I am complaining, but I'm not. I've tried to understand eval() from other resources (books and blog posts), but through reading this book is the first time I truly understand the concept, and why to avoid them. I will update this review once I finished reading the entire book. Please don't take my criticism as discouraging you from buying this book. This book will grant you the comfort and ease to write JavaScript code. However, if you are not pedantic, or only pursuing the operational side of the language (library user), you should skip the series because you will be irritated and hate this book. If you would like to look deep into JavaScript, this is perhaps the only book that will satisfy your desire right now. Btw, this book will tell you how JavaScript is a true and nicely designed programming language with compilers and execution engines. Buy it if you are from a more serious programming background (C/C++, Java, Scala, Lisp...)
S**S
Great and Essential Read!
I have been writing JavaScript for years now and the more I write / read code the more I realize I have a lot to learn. YDKJS: Scope and Closures really helped solidify the open questions I had about closures and what lexical scopes actually were (how they come to be defined). I really enjoyed how scoped (pun intended) this book was. I feel a lot of very valuable information is left out when you write a book to give a general (definitive) overview of the language or its good parts. And with this book, you really are only worried about scopes and closures so you get the full depth of this area without having to consult the rather convoluted standard's specs. Mind you, these are difficult concepts to teach / learn so it was refreshing to see it was all spelled out with great clarity and good examples. I would venture to say that there is probably something, if not, a whole bunch of things that developers will learn from this book. With that, I will be recommending this to all of my colleagues to read and recommending it to anyone who wants to make sure they have a firm understanding of the tools they are wielding. Great work Kyle!
C**C
Recommended for experienced developers!
Before reading the YDKJS books I had been writing JavaScript for several years and had studied some of the "must read" titles like JavaScript: The Good Parts and Flanagan's JavaScript: The Definitive guide. It wasn't until I read Kyle Simpson's YDKJS books (this, Scopes and Closures, and You Don't Know JS: this & Object Prototypes ) that I was able to reach beyond the knowledge I had achieved up to then. Kyle Simpson has a concise and clear writing style. He uses many small examples and explains exactly the principle he's demonstrating. I mentor a team of developers. The YDKJS books are on my "read these first" list for experienced developers transitioning from other languages. Although these books are made available free on the YDKJS GitHub page, I have found them to be so valuable that I have purchased several of the YDKJS series and will probably buy more.
T**R
I would certainly recommend that most developers read this series
I would certainly recommend that most developers read this series. But, this is one of the books that is less revelatory, at least for where I'm at. I've been doing web development for about 5 years now, and still had no clue what closures referred to before reading this. Now that I know, I feel that it's disappointingly unhelpful. That's not to say that understanding scope isn't incredibly essential to writing good code! I mean that closures are more of an academic thing than a practical one. I guess it's cool to change a variable while you're outside the scope it was created in. But, maybe I'm just used to doing more straight-forward scripting than abstracting code to the 3rd degree to achieve a closure. Anyway, the book is worth reading as it does clarify and demonstrate these things quite well.
B**R
Great Job
Great book. I was able to read the whole thing over 3 or 4 lunch breaks. Having learned both of these concepts the hard way, I have been interested in finding a solid, clear, and concise explanation that I can send to new Javascript developers. This is exactly what I was looking for. By taking the time to explain function scope fully (including a great description of how the JS compiler treats JS scripts) first, Kyle makes digesting the explanation of closures very easy. I've read a lot of Javascript books, specifically looking a good explanation for closures. With this book, I have finally found one. -Ben
S**C
A good deep dive into the specific subject of JavaScript Scope and Closures.
Awesome book. This book is targeted toward an experienced JS developer and is an excellent deep dive into the specific subject of JavaScript Scope and Closures. There are plenty of books that try to cover everything JS with varying effectiveness. This one is different... it is a short book with a specific/focused and clear goal (ie read the title) - I like that idea. Once I started reading it I was glued. After finishing it, I want to read the rest of the series. I have suggested this book to several of my experienced JS developer friends and they all say the the same thing. I give this book 5 stars because the writing style is clear, the content is focused and accurate, and it delivers on its promise to teach you things you might not know.
K**A
Voldoet aan alle eisen
Het 2e deel van de YDKJS serie, levering was prima, goed verpakt waardoor het door de brievenbus past. Boek van goede kwaliteit.
C**R
Für jeden, der die Sprache verstehen möchte
Das erste Buch einer ganzen Serie über Javascript im Detail. Kyle Simpson nimmt sich in jedem Band ein Themengebiet vor und behandelt es erschöpfend. Auch für mich, der seit vielen Jahren Javascript im professionellen Umfeld benutzt, war das Buch sehr sehr lehrreich! Wer Probelesen möchte kann das im offiziellen Github Repository der Buchserie tun: [...] Dieses Buch ist jeden Cent wert und ich habe es gerne gekauft, um den Autor zu unterstützen!
C**S
El libro esta en excelente estado y es muy detallada la explicacion
Muy buen detalle de los temas, excelente compra
M**T
Awesome
This is a fantastic book that I wouldn't hesitate recommending to anyone that wants to learn JavaScript properly. This is an awesome series and I'm looking forward to reading the rest of the books.
J**O
Imprescindible!
Libro imprescindible para todos los programadores de JS, realmente no sabía JS! y ahora lo sé!. el estilo de Kyle es ameno, divertido y no se deja nada en el tintero.
Trustpilot
5 days ago
1 week ago