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