-
Notifications
You must be signed in to change notification settings - Fork 23.2k
Modernize JS in Web/API: Use for...of when possible #18103
Description
We are modernizing our code examples in JS.
We would like to use for...of whenever possible, in lieu of for (;;).
This is possible when looping through all the elements of an array:
for (let i=0; i< arrayVar.length; i++) {
[ uses arrayVar[i] ]
should become
for (const arrayValue of arrayVar) {
[ uses arrayValue ]
Note: the arrayValue should be tailored to each case. For example, if arrayVar is cars, arrayValue should be car.
I've created a spreadsheet to help coordinate the different writers. Try to group your changes by APIs, or, when updating unrelated pages, put around 10-15 pages in a PR (not less, it is too fragmented, not more, it becomes difficult to review). Don't overcommit, let everybody have their share.
- Write your name when you start. Next to each file (max. 10 at a time)
- Link to the PR when in
- Mark the lines done when it is merged.
You can take a new batch when your PR is created, no need to wait for it to be merged (except the first time, you don't want to redo the work because of a misunderstanding!)
For your first PR, start with one file only so it is easy to check you have understood.
A few extra tips:
- Mark your PR as a draft (using GitHub UI), if it is not ready for review.
- Choose a useful title, with the API name for example.
- Link to this bug in the PR description using Part of Modernize JS in Web/API: Use for...of when possible #18103.
Feel free to ask any question here. Thanks in advance.