Possible Duplicate:
Why avoid increment (“++”) and decrement (“--”) operators in JavaScript?
I've heard in a few places that it is not recommended to use ++ & -- in javascript, and we should be using += 1 or -= 1 instead. Can anyone clarify why for me?
The only reason I can think of, is that your Javascript is more likely to be edited by a moron than any other code you write (html??).
So to a noob,
x=x+1 ;
is more readable than
x++;
When dealing with experienced programmers, it really doesn't matter.
Because Douglas Crockford has his own opinions of how confusing something may or may not be. They are fine to use, JSLint is just projecting his opinions.
Anyone mind if I make the opposite suggestion...?
Please use the increment (++) and decrement (--) operators when you can. Much more straightforward. (And that's what they're there for.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With