其他分享
首页 > 其他分享> > ESLint for...in 报错

ESLint for...in 报错

作者:互联网

错误提示:for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.eslintno-restricted-syntax The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype.eslintguard-for-in  
for(const name in nameSet) {
 //code
}

将上述for...in循环改成

Object.key(nameSet).forEach((name) => {
       //code
})

错误消失

标签:...,code,over,Object,报错,ESLint,iterate,prototype
来源: https://www.cnblogs.com/Transirizo/p/16410114.html