You Don't Know JS (Volume 1) cover

You Don't Know JS (Volume 1)

Rating 4.5
Word count
270K words
Chapters
19
Series
You Don't Know JS
ISBN
9787115385734

Tags

Summary

You Don't Know JS (Volume 1) is the first book in the You Don't Know JS series and corresponds to the two original English books You Don't Know JS: Scope & Closures and This & Object Prototypes. The book is divided into two main parts. Part One, "Scope and Closures," starts from compilation principles, explaining how the engine, the compiler, and scope work together, then moves on to lexical scope, function and block scope, hoisting, closures, and modules, with appendices on dynamic scope, alternatives to block scope, and lexical this. Part Two, "this and Object Prototypes," systematically lays out the binding rules for this (default binding, implicit binding, explicit binding, new binding, and their precedence and exceptions), then discusses object property descriptors, immutability, [[Get]]/[[Put]], getters/setters, and iteration, before moving to the mixing mechanisms of "classes," the [[Prototype]] chain, prototypal inheritance, and behavior delegation, with an appendix on ES6 class. The author's starting point is to oppose front-end developers' tendency to settle for superficial understanding: many JavaScript features have been blacklisted by developers because they are easy to misuse, and over time the language has been trimmed by developers' usage into something incomplete and dangerous. The book does not teach frameworks or syntax APIs; instead it takes readers back to the language's internal mechanisms to understand why each component is designed the way it is. The book is not long but very dense; its examples are short and build layer by layer, accompanied by many quizzes and summaries, making it suitable for a first read followed by a close reread. This is Volume 1 of the series; the middle and final volumes cover types and grammar, and asynchrony and performance, respectively.

Editor's review

如果你写 JavaScript 的年头已经不算短,却仍然会在看到某个 this 的指向、某个闭包里的变量、某段诡异的提升行为时心里一沉,那么这本书正是为你准备的。它不铺陈语法手册,也不追赶框架热点,而是用两百页左右的篇幅,把“作用域—闭包—this—对象—原型”这条主干从底层重新讲一遍:作用域在编译阶段就被确定,闭包是作用域链的自然结果,this 由调用位置而非书写位置决定,原型链才是 JavaScript 真正的继承机制。作者的叙述节奏很好,几乎每个抽象概念都会配一个短小例子,先用反直觉的输出制造疑问,再一层层拆开引擎的行为,最后用小测验让你自己动手验证。很多人读完的感受是:原来过去十几年是“猜”着用这门语言的。图灵程序设计丛书的这个中文版由赵望野、梁杰翻译,术语处理克制、行文通顺,正文与附录的取舍也贴合国内读者的学习路径。对于希望摆脱“能跑就行”、真正建立语言底层模型的开发者,这是性价比极高的一本。

Who it's for

A good fit for

  • 已能写日常业务代码、希望弄清 this 与闭包究竟如何工作的前端开发者
  • 准备前端面试、需要系统梳理作用域与原型链知识体系的人
  • 从其他语言转来、想理解 JavaScript 独特对象模型的后端或全栈程序员
  • 计算机相关专业学生,作为《JavaScript高级程序设计》之后的进阶读物

Not a good fit for

  • 完全没有 JavaScript 基础、需要先学语法与 DOM 操作零基础入门者
  • 只想找框架、工程化或组件库实战教程的读者
  • 期待大量完整项目案例、边做边学的读者

Reading tips

  1. 先通读一遍建立整体图景,再对 this 绑定规则与闭包两章逐例手敲验证。
  2. 读每个例子时先遮住输出自己预测结果,再运行对照,差异处就是知识缺口。
  3. 读完上卷可顺次衔接中卷(类型与语法)与下卷(异步与性能),形成完整认知。
  4. 配合浏览器控制台或 Node 环境练习,遇到结论存疑时以实际运行结果为准。

About the publisher

Posts & Telecom Press China · Founded in 1953

Posts & Telecom Press is known for its strengths in science and technology, computing, and information and communications titles, and has extended its publishing into photography, art, software learning, and inspirational growth, giving it a fairly diverse range. Its catalog includes computing and communications works such as Refactoring and Patterns (Revised Edition) and Huawei Switch Learning Guide (Second Edition), alongside bilingual collector's editions such as The Little Prince (Chinese-English-French illustrated collector's edition), The Great Gatsby, and Three Days to See. Beijing Ten Years: 1980-1990 and Ghost Blade: WLOP Personal Illustration Collection reflect its presence in photography and art. Its authors include Antoine de Saint-Exupéry, Helen Keller, Joshua Kerievsky, Wang Da, Zhang Zhaozeng, and WLOP.

Contents

  1. Preface
  2. Part I Scope and Closures
  3. Chapter 1 What Is Scope? (Compilation Theory, Understanding Scope, Nested Scope, Exceptions)
  4. Chapter 2 Lexical Scope (Lexical Stage, Deceiving Lexical Scope: eval and with)
  5. Chapter 3 Function Scope and Block Scope (Hiding Internal Implementation, Anonymous vs. Named, IIFE, with, try/catch, let, const)
  6. Chapter 4 Hoisting (The Compiler Strikes Again, Functions First)
  7. Chapter 5 Scope Closures (The Real Question, Loops and Closures, Modules, Modern and Future Module Mechanisms)
  8. Appendix A Dynamic Scope
  9. Appendix B Alternatives to Block Scope
  10. Appendix C Lexical this
  11. Appendix D Acknowledgments
  12. Part II this and Object Prototypes
  13. Chapter 1 About this (Why Use this, Common Misconceptions, What this Really Is)
  14. Chapter 2 this in Full (Call Site, Default Binding, Implicit Binding, Explicit Binding, new Binding, Precedence, Binding Exceptions, Soft Binding, Lexical this)
  15. Chapter 3 Objects (Syntax, Types, Contents, Computed Property Names, Property Descriptors, Immutability, [[Get]] and [[Put]], Getters and Setters, Existence, Iteration)
  16. Chapter 4 Mixing "Class" Objects (Class Theory, The Mechanics of Classes, Class Inheritance, Polymorphism, Multiple Inheritance, Explicit and Implicit Mixins)
  17. Chapter 5 Prototypes ([[Prototype]], Prototypal Inheritance, Object Association)
  18. Chapter 6 Behavior Delegation (Delegation-Oriented Design, Classes vs. Objects, Simpler Design, Introspection)
  19. Appendix A class in ES6

FAQ

这本书适合零基础学 JavaScript 吗?
不太适合。本书假定读者已有基本的 JavaScript 使用经验,重点讲语言内部机制而非语法入门。零基础读者建议先读《JavaScript高级程序设计》一类入门书,再回来读本书收获更大。
上卷、中卷、下卷分别讲什么?
上卷讲作用域与闭包、this 与对象原型;中卷对应类型与语法;下卷对应异步与性能。三册主题相对独立,可按兴趣选读,但按上、中、下顺序读最顺。
中文版和英文原版内容一致吗?
上卷中文版合并了原书 Scope & Closures 与 This & Object Prototypes 两部分,主体章节与附录基本对应原书结构,个别版式与附录编排有调整,核心内容一致。
书里的示例过时了吗,还值得读吗?
书中讨论的是作用域、闭包、this、原型等语言核心机制,这些机制多年来变化很小,因此主体内容并不过时;涉及模块与 ES6 语法的部分可结合当前规范补充阅读。
读完能显著提升面试表现吗?
对作用域、闭包、this 指向、原型链、继承等高频考点帮助直接而明显,但本书不做面试题汇编,需要自己把书中结论转化为可表述的答案并配合练习。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category