Effective JavaScript

David Herman

出版时间

2012-12-06

ISBN

9780321812186

评分

★★★★★
书籍介绍
这本书的真正价值,在于它不教你怎么写JavaScript,而是教你为什么某些写法会出错。它把语言里那些'看起来应该返回null却返回对象'、'eval会污染调用者作用域'、'named function expression的scope会被Object.prototype动态影响'等反直觉行为逐一拆解,并指出哪些是规范遗留的历史错误、哪些是必须绕开的陷阱。读者反馈两极分化:有人因此理清了难懂的概念、直呼'神书',也有人抱怨'偏重原理、部分章节鸡肋'。它适合不满足于'能跑就行'、愿意追问机制的开发者;若只想找速成技巧,可能会觉得枯燥。
AI导读
核心看点
  • 作者为JS规范专家,内容权威且深入。
  • 涵盖作用域、原型等核心概念,干货满满。
  • 提供大量实战建议,帮助规避常见陷阱。
读者共识
  • Effective系列经典,对得起其高口碑。
  • 讲解生动不枯燥,是JS进阶必读好书。
  • 部分观点有争议,需辩证看待并批判吸收。
精彩摘录
  • "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"
  • "正常的作用域中,会有与局部作用域中的变量同样多的作用域绑定储存在与之对应的环境层级中。但对于with作用域,绑定集合依赖于碰巧在给定时间点的对象。"
用户评论
后面大部分内容都已经知道了,要是 2012 年看的话收获就非常大了。
啃书太慢怎么破....
对初学者很有用 但是更像是recipes 零零散散的知识点
好书
满满的干货,对于闭包closure, this以及异步concurrency讲的很透,能感觉到作者真正是厚积薄发
国内引进的英文版封面不是这样的。封面错了,拒绝写书评。
虽然有点过时,但是依然很有帮助!帮我理清了一些难懂的javascript概念
这本书的点太追求技术、太偏了,原理解释得也很蹩脚,不推荐。
下载
收藏