3 ms·
Most of the array methods are explicitly defined in terms of indexing rather that iterators, so for(of) is incorrect. On the other hand indexing is still faste
by olliej 12y ago
Most of the array methods are explicitly defined in terms of indexing rather that iterators, so for(of) is incorrect. On the other hand indexing is still faster than iteration in the major implementations.
- Excavator 12y agoMy comment were intended as a direct reply to phpnode's code, 'ignoring' the rest of the thread. How do you mean when you state that for(of) is incorrect? Perhaps this 'example' clears something up? « for (value in {a:1,b:2,c:3,d:4,e:5}) console.log(value) » undefined "a" "b" "c" "d" "e" « for (value of {a:1,b:2,c:3,d:4,e:5}) console.log(value) × TypeError: ({a:1, b:2, c:3, d:4, e:5})['@@iterator'] is not a function