TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

10 Javascript Shorthand Coding Techniques

3 点作者 chris_engel将近 14 年前

2 条评论

ionfish将近 14 年前
Aside from the fact that it's basically blogspam which does a poor job of explaining common JavaScript idioms, articles like this are dangerous because of what they <i>don't</i> say.<p>In (2), for example, they suggest using the short-circuit feature of the || operator in assignments, and mention that a null, undefined or empty string value on the left will make the assignment fall through to the value on the right hand side. What this fails to mention is that any value that converts to false will trigger the fall-through: this includes 0, false, and NaN and well as the values already mentioned.<p>(9) is really pernicious since it neither explains the real uses of the arguments object, nor mentions how it can screw up the public interface your functions provide. For example, if a function has no named arguments it will have a length property of 0. This can screw up all kinds of handy stuff like higher-order programming.
mooism2将近 14 年前
This is dire. For example:<p>&#62; When doing “if checks” assignment operators can sometimes be ommited.<p>Should be comparison operators.<p>And more broadly, at this level you should explain boolean values.