0

重複の可能性:
jslint エラー: 予期しない 'in'。undefined と比較するか、hasOwnProperty を使用します

jslint がこのコードについて不平を言う理由と、どのように修正すればよいでしょうか。

            if ('children' in object) {
                for (key in object.children) {
                    recurse(object.children[key], key);
                }
            }

明らかに再帰が定義されています。

4

1 に答える 1

1

変数がありません。また、「hasOwnProperty」を使用していません。

if (object.hasOwnProperty('children')) {
    for (var key in object.children) {
        if(object.children.hasOwnProperty(key)) {
            recurse(object.children[key], key);
        }
    }
}
于 2012-08-29T13:46:41.940 に答える