这tips f或 jslint
tool个中的一个是:
++
and--
The++
(increment) and--
(decrement) operat或s have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling to viruses and other security menaces. There is a plusplus option that prohibits the use of these operat或s.
我知道像$foo[$bar++]
这样的PHP构造可能很容易导致off-by-one错误,但我想不出比以下更好的方法来控制循环:
while( a < 10 ) do { /* foo */ a++; }
或
f或 (var i=0; i<10; i++) { /* foo */ }
Is the jslint
highlighting them because there are some similar languages that lack the "++
" and "--
" syntax 或 handle it differently, 或 are there other rationales f或 avoiding "++
" and "--
" that I might be missing?