Why avoid increment (“++”) and decrement (“–“) operators in JavaScript?

My view is to always use ++ and — by themselves on a single line, as in:

i++;
array[i] = foo;

instead of

array[++i] = foo;

Anything beyond that can be confusing to some programmers and is just not worth it in my view. For loops are an exception, as the use of the increment operator is idiomatic and thus always clear.

Leave a Comment