You Don't Know JS: Types & Grammar / Async & Performance cover

You Don't Know JS: Types & Grammar / Async & Performance

Rating 4.4
Word count
295K words
Chapters
1
Series
You Don't Know JS
ISBN
9787115431165

Tags

Summary

You Don't Know JS: Types & Grammar / Async & Performance is the middle volume of Kyle Simpson's You Don't Know JS series, translated by Shan Ye and Jiang Nan and published by Posts & Telecom Press under the Turing imprint. The book is divided into two major thematic parts. Part One, "Types & Grammar," systematically lays out JavaScript's type system and grammar rules: starting from the seven built-in types and the pitfalls of typeof, it analyzes the details of arrays, strings, and numbers (including IEEE 754 precision issues, the safe integer range, NaN, -0, and other special values), then discusses native functions and the boxing and unboxing of wrapper objects, before focusing on coercion—abstract value operations, explicit and implicit conversion, the comparison rules for loose and strict equality, and abstract relational comparison. Finally it covers statement- and expression-level pitfalls such as operator precedence, automatic semicolon insertion, errors, and try…finally, closing with an appendix on "Mixed Environment JavaScript." Part Two, "Async & Performance," begins with the event loop and concurrency model, explaining why single-threaded JavaScript still needs asynchrony; it then examines the control inversion and trust problems of callback-based asynchrony, delves into Promise patterns, chained flow, and error handling, and uses generators (with yield and iterators) to achieve synchronous-style asynchronous flow control; lastly it discusses program performance, including Web Workers, SIMD, asm.js, and the methodology of benchmarking and tuning, with appendices on the asynquence library and advanced asynchronous patterns. Throughout, the book uses numerous code snippets and counterexamples to clear up common misconceptions; its aim is not to teach you to call APIs but to help you truly understand the language's own mechanisms.

Editor's review

很多人写 JavaScript 多年,靠的是“试出来的经验”:== 什么时候能用、this 为什么变了、回调嵌套该怎么救。这本书偏偏要回到语言本身,把这些“说不清”的地方一条条拆开。 中卷的两个主题,恰好是工作中出错最多、面试里也最常被问的部分。类型和语法这一半,把强制类型转换讲到让人心服口服——包括抽象值操作、ToPrimitive、宽松相等的比较规则、运算符优先级和自动分号插入;异步那一半,则顺着事件循环一路讲到回调、Promise 与生成器,讲清“为什么异步”和“怎样把异步写成可读的同步风格”。 两位译者的分工也挺讲究:姜南译“类型和语法”,单业译“异步和性能”,都是各自熟悉的部分。书里的代码示例密度高,读起来不快,但每个坑都配有可以亲手验证的片段。 和市面上罗列 API 的教程不同,它更像是给已有基础的开发者做一次“认知纠偏”。适合放在手边,遇到奇怪的行为就翻一翻对应章节。

Who it's for

A good fit for

  • 有一到两年 JavaScript 使用经验、想弄懂语言底层机制的开发者
  • 准备前端技术面试,需要系统梳理类型转换、this、异步等考点的人
  • 正在被回调嵌套和 Promise 链困扰、想提升异步代码质量的前端工程师
  • 前端团队负责人,可作为内部共读或新人进阶的参考书

Not a good fit for

  • 零基础、还没写过 JavaScript 代码的读者,建议先看入门教程
  • 只想要现成框架和组件用法、不关心语言原理的开发者
  • 主要做后端或数据方向、几乎不接触 JavaScript 的读者

Reading tips

  1. 先读第一部分“类型和语法”,把强制类型转换和运算符优先级两章配合控制台动手验证
  2. 读异步部分时,用浏览器或 Node 打开事件循环示例,边跑代码边对照 Promise 与生成器章节
  3. 建议与上卷、下卷按顺序配合阅读,中卷偏重语言机制与异步模型
  4. 把书中的反例整理成自己的笔记或测试用例,遇到线上疑难问题时回头检索

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. You Don't Know JS

FAQ

这本书和上卷、下卷是什么关系?
三册同属“你不知道的JavaScript”系列,主题各有侧重:上卷讲作用域与闭包、this 与对象原型;中卷讲类型和语法、异步和性能;下卷涉及 ES6 及语言未来。中卷可以单独读,但先有上卷基础会更顺畅。
读这本书需要什么基础?
至少能熟练写函数、数组、对象和基本 DOM 操作,理解变量与作用域。书里不教语法入门,而是解释机制,所以零基础读者容易卡住。
书里的内容现在会不会太旧?
书基于 ES5 与早期 ES6 编写,事件循环、类型转换、Promise 与生成器这些核心机制至今仍然成立;但部分语法提案与性能方案(如 asm.js)已有变化,阅读时应对照当前的 MDN 文档。
中文版是谁翻译的?
中文版由单业、姜南翻译,人民邮电出版社出版,属图灵程序设计丛书。其中姜南负责“类型和语法”部分,单业负责“异步和性能”部分。

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