What does the JSLint error 'body of a for in should be wrapped in an if statement' mean?

后端 未结 8 870
长情又很酷
长情又很酷 2020-11-30 15:57

I used JSLint on a JavaScript file of mine. It threw the error:

for( ind in evtListeners ) {

Problem at line 41 character 9:

8条回答
  •  悲&欢浪女
    2020-11-30 16:35

    Vava's answer is on the mark. If you use jQuery, then the $.each() function takes care of this, hence it is safer to use.

    $.each(evtListeners, function(index, elem) {
        // your code
    });
    

提交回复
热议问题