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 var
if thing
has not been previously declared.
for ( var thing in things ) {
console.log(thing)
}
or
var thing;
//more code
for ( thing in things ) {
console.log(thing)
}
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