Skip to content

Commit

Permalink
Reference for...of statement before usage in example (#24715)
Browse files Browse the repository at this point in the history
* Reference for...of statement before usage in example

The 'Showing file(s) size' example includes a for...of statement to iterate through the file array. However, this has not been introduced previously in the page (instead a for loop with an iteration variable was used just above). To prevent potential confusion, this change mentions the for...of statement and gives a snippet of how to use it before it's referenced.

Alternatively, I'd suggest changing the 'Showing file(s) size' example to use a for loop with an iteration variable for consistency.

* Remove file iteration examples

Readers will be familiar with looping through arrays, so the `for (;;)` and `for...of` snippets are not required.
  • Loading branch information
daverayment authored Mar 15, 2023
1 parent d2c7c7f commit 8601619
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,7 @@ The {{DOMxRef("FileList")}} object provided by the DOM lists all of the files se
const numFiles = fileList.length;
```

Individual {{DOMxRef("File")}} objects can be retrieved by accessing the list as an array:

```js
for (let i = 0, numFiles = fileList.length; i < numFiles; i++) {
const file = fileList[i];
//
}
```

This loop iterates over all the files in the file list.
Individual {{DOMxRef("File")}} objects can be retrieved by accessing the list as an array.

There are three attributes provided by the {{DOMxRef("File")}} object that contain useful information about the file.

Expand Down

0 comments on commit 8601619

Please sign in to comment.