Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected '++' in jslint [duplicate]

Possible Duplicate:
Why avoid increment (“++”) and decrement (“--”) operators in JavaScript?
The “unexpected ++” error in jslint

jslint.com is giving me the error:

Unexpected '++'.

for this line:

for (i = 0; i < l; ++i) {

I tried i++ but no go.

like image 964
morph_master_flex Avatar asked Aug 16 '12 22:08

morph_master_flex


1 Answers

JSLint does not like the increment and decrement operators. Replace it with i += 1 or add the plusplus: true directive to the top of your file (if you're not sure how to set JSLint directives, here's an example. They are set in a normal comment at the top of your file):

/*jslint plusplus: true */

From the JSLint docs:

The ++ (increment) and -- (decrement) operators 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.

Completely ridiculous rule? You can make your own mind up...

like image 73
James Allardice Avatar answered Oct 02 '22 08:10

James Allardice