The following code:
var things = {'foo':'bar'}
for ( thing in things ) {
console.log(thing)
}
Consistently produces the following error in jshint:
Bad for in variable 'thing'.
I do not understand what makes the ‘thing’ variable ‘bad’ – as you can see, it is not being used anywhere else. What should I do differently to make jshint not consider this to be an error?
They always are – if they are not declared. Try adding
varifthinghas not been previously declared.or