-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modernize JS in Web/API: Use for...of when possible #18103
Comments
Are you open to using iterators besides the implicit // increment each element
for (let index = 0; index < sequence.length; ++index) {
sequence[index] += 1;
} -> // increment each element
for (const index of sequence.keys()) {
sequence[index] += 1;
} (no, this isn't a snippet from from MDN) |
And I believe that I've encountered |
The list I created contains only For |
No, that was specifically what I had in mind: particularly If I find time, I may help out with a more thorough search, and extend this to more cases. |
We fixed one of these |
This is mostly done. There may a few cases here or there, but no need to keep this open. |
We are modernizing our code examples in JS.
We would like to use
for...of
whenever possible, in lieu offor (;;)
.This is possible when looping through all the elements of an array:
should become
Note: the arrayValue should be tailored to each case. For example, if arrayVar is
cars
, arrayValue should becar
.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.
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:
Feel free to ask any question here. Thanks in advance.
The text was updated successfully, but these errors were encountered: