JavaScript: The Good Parts cover

JavaScript: The Good Parts

Rating 4.5
Word count
110K words
Chapters
18
ISBN
9787121084379

Tags

Summary

JavaScript: The Good Parts, by Douglas Crockford, is the Chinese translation of the widely circulated classic short book on JavaScript. Crockford argues that JavaScript has long been called "the most misunderstood language" because it was born in haste, mixing excellent design with terrible design; yet within it there truly exists a stable, readable, maintainable subset sufficient for elegant and efficient code. The book covers nine areas—syntax, objects, functions, inheritance, arrays, regular expressions, methods, code style, and beautiful features—dissecting the language's true essence layer by layer: object literals, prototypal inheritance, closures, function invocation patterns, modules, and memoization are all explained with extreme concision and clarity. Appendices gather the "bad parts" and "awful parts," warning readers away from global variables, automatic semicolon insertion, reserved words, floating-point numbers, and pseudo-arrays, and introduce the JSLint validation tool and JSON (which the author himself popularized). The Chinese edition is short and restrained in prose—less an introductory tutorial than a training in judgment about "how to use only the good parts of the language."

Editor's review

这本书只有一百多页,却被一代前端开发者反复翻阅,原因在于它谈的不是 API 清单,而是判断力。多数 JavaScript 教材教你怎么把功能做出来,Crockford 教的是哪些功能根本不该用:他不试图为语言辩护,而是像设计师一样把语言拆成“精华”“鸡肋”“毒瘤”三类,然后建议你只留下第一类。书中对函数、闭包、原型继承、模块模式的讲解干净利落,寥寥数页就能讲清别处要绕很多弯才说清的概念。作者是 JSON 格式的创造者、ECMAScript 委员会成员,被 Brendan Eich 称作“JavaScript 的大宗师”,其观点带有强烈的个人风格;正因如此,读它更像听一场立场鲜明的大师课。需要提醒的是,本书成书于 ES5 之前,关于代码风格、JSLint 及部分“优美特性”的看法,在今天已有讨论余地;但它关于语言本质的那部分内容并不过时。

Who it's for

A good fit for

  • 已有一定 JavaScript 使用经验、想弄清语言本质的中级开发者
  • 希望改善代码风格、减少踩坑的前端工程师
  • 从 Java、C++ 等强类型语言转来、对 JS 心存疑虑的程序员
  • 想训练技术判断力、愿意读薄书的工程师与团队负责人

Not a good fit for

  • 完全没有编程经验、需要系统入门的零基础读者
  • 只想找现成框架或项目实战教程的读者
  • 专门研究 ES6+ 新特性、希望紧跟最新标准的读者

Reading tips

  1. 先通读第1章与附录A、附录B,建立“哪些不要用”的底线意识,再回头细读函数与继承两章。
  2. 第4章与第5章值得配上代码动手改写,把闭包、模块、函数化继承亲手实现一遍。
  3. 留意成书年代的局限:读到代码风格与优美特性部分时,对照当下的 ES 规范与主流风格指南辩证看待。
  4. 篇幅短、信息密,适合当作工具书放在手边,遇到语言困惑时按主题回查对应小节。

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. Foreword
  2. Chapter 1: Good Parts—Why JavaScript, Analyzing JavaScript, A Simple Testing Ground
  3. Chapter 2: Grammar—Whitespace, Identifiers, Numbers, Strings, Statements, Expressions, Literals, Functions
  4. Chapter 3: Objects—Object Literals, Retrieval, Update, Reference, Prototype, Reflection, Enumeration, Delete, Reducing Global Pollution
  5. Chapter 4: Functions—Function Objects, Function Literals, Invocation, Arguments, Return, Exceptions, Augmenting Types, Recursion, Scope, Closure, Callback, Module, Cascade, Currying, Memoization
  6. Chapter 5: Inheritance—Pseudoclassical, Object Specifiers, Prototypal, Functional, Parts
  7. Chapter 6: Arrays—Array Literals, Length, Delete, Enumeration, Confusion, Methods, Dimensions
  8. Chapter 7: Regular Expressions—An Example, Construction, Elements
  9. Chapter 8: Methods—Array, Function, Number, Object, RegExp, String
  10. Chapter 9: Style
  11. Chapter 10: Beautiful Features
  12. Appendix A: Awful Parts
  13. Appendix B: Bad Parts
  14. Appendix C: JSLint
  15. Appendix D: Syntax Diagrams
  16. Appendix E: JSON
  17. Index
  18. About the Author

FAQ

这本书适合零基础学 JavaScript 吗?
不太适合。全书假设读者已写过 JavaScript,重点在于辨析语言优劣而非从语法起步。零基础读者建议先学完一门入门教程,再回读本书,收获会明显更大。
这本书和《JavaScript语言精粹(修订版)》有什么区别?
两者译者相同,均为赵泽欣、鄢学鹍。初版 2009 年由电子工业出版社出版,ISBN 为 9787121084379;修订版 2012 年出版(2021 年有重印),ISBN 为 9787121177408,内容框架一致。选购时注意核对版本与 ISBN。
书里讲的 ES5 之前的观点现在还适用吗?
关于函数、闭包、原型继承、对象字面量等语言本质的部分依然适用;而代码风格、JSLint 偏好、部分“优美特性”的取舍,在 ES6 之后已有不同看法,建议结合当下规范辩证阅读。
书中的 JSLint 与 JSON 附录值得看吗?
值得。作者是 JSON 格式的主要推广者,附录E对 JSON 语法边界的说明简洁权威;附录C则展示了他对代码校验的严苛标准,有助于理解其整体技术立场。

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