I have a for loop in JavaScript that I have run through JSLint a few times. In the past I received the unexpected++ error
, I decided to refactor to make my code more readable. A month or so later JSLint came out with an update and is now showing the warning...
Unexpected expression 'i' in statement position. for (i; i < scope.formData.tabs.length; i = i + 1) {
//See JSLint.com for why I pulled out i initialization and i = i+1 instead of i++
//and http://stackoverflow.com/questions/3000276/the-unexpected-error-in-jslint
var i = 0;
for (i; i < scope.formData.tabs.length; i += 1) {
scope.formData.tabs[i].show = false; // hide all the other tabs
if (scope.formData.tabs[i].title === title) {
scope.formData.tabs[i].show = true; // show the new tab
}
}
Reverting to var i = 0
and i++
does not get improve the warnings, JSLint just stops processing.