If I understand correctly, the reason in JSLint is that there is a significant difference between ++i and i++ , and many developers do not necessarily evaluate the consequences of when they are performed with respect to the addition, with respect to other operations around it.
eg:
var i = 0; if(i++) { //does this get run or not? } if(--i) { //and what about this one? }
That's why Crockford considers this a bad practice and prefers a more explicit +=1 .
However, in general, I have no such problem with ++ ; I would love to use it, and I would ignore JSLint telling me not to (most of the time!).
This is an important thing in JSLint - it does not mean real errors; all he tells you is an offer. Some of them are great suggestions (for example, you should never use with ); some of them are good suggestions that indicate bad code; and some of them are only a problem at some points in time and should be considered individually. As a developer, itβs more important that you know why he makes an offer, and not actually fix them. Once you understand the reasons why they are indicated, you can decide for yourself whether this instance of it in your code is a problem or not and how to fix it.
Hope this helps.
source share