不推荐使用for..in,推荐使用-Object.keys。涉及原型链

76 阅读1分钟

eslint 不推荐使用 for..in。推荐使用 Object.{keys,values,entries} 因为 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