David Herman,资深 JavaScript 技术专家,Ecma TC39 委员会成员,负责JavaScript 的标准化工作。他拥有格林内尔学院的计算机科学学士学位和美国东北大学的计算机科学硕士及博士学位,现在 Mozilla 研究院担任高级研究员。
AI导读
核心看点
ECMA专家撰写,浓缩68条实践建议
深度解析JS内部机制、陷阱与最佳实践
涵盖作用域、函数、原型及并发等核心主题
读者共识
内容权威实用,对编写高质量JS代码帮助大
翻译质量参差不齐,部分代码存在勘误问题
部分观点随ES6普及已过时,理念仍具参考价值
精彩摘录
"The specification mistake, which existed through ES3, was that JavaScript engines were required to represent the scope of a named function expression as an object, much like the problematic with construct. This program looks like it should produce null, but it actually produces a new object, because"
"The other kind of call to eval is considered “indirect,” and evaluates its argument in global scope."
"A concise way to write an indirect call to eval is to use the expression sequencing operator (,) with an apparently pointless number literal:"
"a new arguments variable is implicitly bound in the body of each function.a The arguments object we are interested in is the one associated with the values function, but the iterator’s next method contains its own arguments variable. So when we return arguments[i++], we are accessing an argument of "
"JavaScript engines are not required to produce accurate reflections of function source code via `toString`"
"Different engines may produce different results from `toString`"
"Overloading two types means there must be a way to distinguish the cases. And it’s not possible to detect that a value implements a structural interface. This leads to the following rule: APIs should never overload structural types with other overlapping types"