1
为什么jshint不报告以下代码的forin(hasOwnProperty)错误? jslint会报告错误,但jshint不会。forin(hasOwnProperty)jshint没有错误
/*jshint forin: true */
(function() {
"use strict";
var obj = {a: 1, b: 2}, i = null;
for (i in obj) {
if (i === 0) {
console.log('blah...');
}
}
}());
哦,我明白了!这不是一个错误,而是设计。非常感谢答案:) – iFadey
良好的通话。只是为了说明为什么JSLint *工作,[JSLint的当前代码](https://github.com/douglascrockford/JSLint/blob/c657984cd7dfc17277feadb86d1de24c664f944a/jslint.js)具有明确检查'hasOwnProperty'的'if'之后的'for'(而不是JSHint唯一检查“if”)的第3687行开始的'case'块。 – ruffin