Merge pull request #747 from 11un/patch-6

typo / language edit
This commit is contained in:
Ilya Kantor 2019-01-21 22:15:13 +03:00 committed by GitHub
commit 1714051f9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -320,7 +320,7 @@ But that's actually a bad idea. There are potential problems with it:
There are so-called "array-like" objects in the browser and in other environments, that *look like arrays*. That is, they have `length` and indexes properties, but they may also have other non-numeric properties and methods, which we usually don't need. The `for..in` loop will list them though. So if we need to work with array-like objects, then these "extra" properties can become a problem. There are so-called "array-like" objects in the browser and in other environments, that *look like arrays*. That is, they have `length` and indexes properties, but they may also have other non-numeric properties and methods, which we usually don't need. The `for..in` loop will list them though. So if we need to work with array-like objects, then these "extra" properties can become a problem.
2. The `for..in` loop is optimized for generic objects, not arrays, and thus is 10-100 times slower. Of course, it's still very fast. The speedup may matter only in bottlenecks or just irrelevant. But still we should be aware of the difference. 2. The `for..in` loop is optimized for generic objects, not arrays, and thus is 10-100 times slower. Of course, it's still very fast. The speedup may only matter in bottlenecks or seem irrelevant. But still we should be aware of the difference.
Generally, we shouldn't use `for..in` for arrays. Generally, we shouldn't use `for..in` for arrays.