显而易见,隐式转换大坑with Statement#
// @Deprecated 来自官方的声明
with ([1, 2, 3]) {
console.log(toString()); // 1,2,3
}
eval#
破坏性巨大continue Statement#
The continue statement jumps to the top of the loop. I have never seen a piece of code that was not improved by refactoring it to remove the continue statement.
switch Fall Through#
一定要写defaultBlock-less Statements#
不会有人不写闭括号吧?
Style 原因
In my own practice, I observed that when I used ++ and--,my code tended to be too tight, too tricky, too cryptic.
Bitwise Operators#
啥?JS操作比其他语言慢多了!
In most languages, these operators are very close to the hardware and very fast. In JavaScript, they are very far from the hardware and very slow.
The function Statement Versus the function Expression#
函数会hoisted,函数定义在 if 语句会很奇怪!
<span style="font-family: ''; font-size: 13.028571128845215px">function f() {}; // func statement</span>
<span style="font-family: ''; font-size: 13.028571128845215px">const f = function () {} // func expression</span>
Typed Wrappers#
编者:没必要new#
编者:new Function 的时候如果遗忘了 new 关键字,会造成blabla问题!
本人:new 都忘了写,会有 bug 不是很正常的!据说 new 参考 Java 而引进的,可 Java 都是 new Class(),JS 里面的 new Function() ,是什么混合写法?函数式?对象式?void#
In many languages, void is a type that has no values. In JavaScript, void is an operator that takes an operand and returns undefined. This is not useful, and it is very confusing. Avoid void.