Re: Unexpected use of ++
- --- In email@example.com, "grahamj_42" <grahamj42@...> wrote:
> var i;
> for ( i=0 ; i<10 ; i++ )
> /* some code */
> The i++ here is straight from K&R C, and so should be expected! I
> haven't found a previous remark about this in the group, so is it a
> new feature?
One of the premises of a code quality tool is that there are features in languages that are problematic. The problem with bad parts isn't that they are useless, but that they are dangerous. They should be avoided if there are safer alternatives.
In my opinion, ++ and -- are dangerous. They have been implicated in some of the worst OS security bugs. And they seem to confuse people who sometimes use i++ when the mean ++i (as you just did). Confusion leads to bugs.
So JSLint has an option to warn when they are used. If you are wise, you will change your code to i += 1. But if you choose not to, then stop turning that option on.