for statement with index and value
Tingan Ho
tingan87 at gmail.com
Tue Jul 14 02:43:32 UTC 2015
>for (let [index, value] of [1, 2, 3].entries())
console.log(index + ": " + value)
I still think most people will write:
```
for (let value of values) { ... }
```
and then rewrite the whole expression inside the `for-loop` when they find
out that they need the index too:
```
for (let [index, value] of [1, 2, 3].entries())
console.log(index + ": " + value)
```
`for (let value, index of values) { ... }` is still much easier to type
than `for (let [index, value] of [1, 2, 3].entries())` and also more
readable.
Also, doesn't that makes a copy of the `[1, 2, 3]`?
--
Sincerely,
Tingan Ho
@tingan87 <https://twitter.com/tingan87>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150714/8b4cf121/attachment-0001.html>
More information about the es-discuss
mailing list