最后更新于:2022-04-02 02:02:46

> 原文出处:https://github.com/getify/You-Dont-Know-JS/blob/1ed-zh-CN/scope%20&%20closures/README.md#you-dont-know-js-scope--closures # Foreword For You Don't Know JS Published on [June 03, 2014](https://shanehudson.net/2014/06/03/foreword-dont-know-js) I had the honour of writing the foreword for the first book, [Scope & Closures](http://www.amazon.co.uk/gp/product/1449335586/ref=as_li_ss_tl?ie=UTF8&camp=1634&creative=19450&creativeASIN=1449335586&linkCode=as2&tag=4534535-21), of Kyle Simpson's [You Don't Know JS](https://www.kickstarter.com/projects/getify/you-dont-know-js-book-series) series. I urge you to buy the book, it is definitely worth a read no matter your skill or experience, but I've also included the foreword below. When I was a young child, I would often enjoy taking things apart and putting them back together again. Old mobile phones, Hi-Fi stereos and anything else I could get my hands on. I was too young to really use these devices, but whenever one broke, I would instantly ask if I could figure out how it worked. I remember once looking at a circuit board for an old radio. It had this weird long tube with copper wire wrapped around it. I couldn't work out its purpose, but I immediately went into research mode. What does it do? Why is it in a radio? It doesn't look like the other parts of the circuit board, why? Why does it have copper wrapped around it? What happens if I remove the copper?! Now I know it was a loop antenna, made by wrapping copper wire around a ferrite rod, which are often used in transistor radios. Did you ever become addicted to figuring out all of the answers to every 'why' question? Most children do. In fact it is probably my favourite thing about children - their desire to learn. Unfortunately, now I'm considered a 'professional' and spend my days making things. When I was young, I loved the idea of one day making the things that I took apart. Of course, most things I make now are with JavaScript and not ferrite rods... but close enough! However, despite once loving the idea of making things, I now find myself longing for the desire to figure things out. Sure - I often figure out the best way to solve a problem or fix a bug, but I rarely take the time to question my tools. And that is exactly why I am so excited about Kyle's "You Don't Know JS" series of books. Because he is right. I don't know JS. I use JavaScript day in, day out and have done for many years, but do I really understand it? No. Sure, I understand a lot of it and I often read the specs and the mailing lists, but no, I don't understand as much as my inner 6 year old wishes I did. Scope and Closures, is a brilliant start to the series. It is very well targeted at people like me (and hopefully you too), it doesn't teach JavaScript as if you've never used it but it does make you realise how little about the inner workings you probably know. It is also coming out at the perfect time, ES6 is finally settling down and implementation across browsers is going well. If you've not yet got around to learning the new features (such as let and const), this book will be a great introduction. So I hope that you enjoy this book, but more so that Kyle's way of critically thinking about how every tiny bit of the language works, will creep into your mindset and general workflow. Instead of just using the antenna, figure out how and why it works.
';