Skip to content

Commit

Permalink
Consistently use 3 dots for for...of/in (mdn#20317)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena authored Sep 5, 2022
1 parent d57110c commit ba66c42
Show file tree
Hide file tree
Showing 20 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/13/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Firefox 13 was shipped on June 5, 2012. This page summarizes the changes in Fire

### JavaScript

- Support for the ECMAScript 2015 [`for..of`](/en-US/docs/Web/JavaScript/Reference/Statements/for...of) construct has been added.
- Support for the ECMAScript 2015 [`for...of`](/en-US/docs/Web/JavaScript/Reference/Statements/for...of) construct has been added.
- Experimental support for ECMAScript 2015 [Map](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) and [Set](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) objects has been implemented.

### DOM
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/17/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Firefox 17 shipped on November 20, 2012. This article lists key changes that are
- Support to iterate [`Map`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)/[`Set`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) ({{bug("725909")}}).
- Disabled [E4X](/en-US/docs/E4X) for web content by default ({{bug("778851")}}).
- `__exposedProps__` must now be set for Chrome JavaScript objects exposed to content. Attempts to access Chrome objects from content without `__exposedProps__` set will fail silently ({{bug("553102")}}).
- [`for..of`](/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loops now work in terms of `.iterator()` and `.next()` ({{bug(725907)}}).
- [`for...of`](/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loops now work in terms of `.iterator()` and `.next()` ({{bug(725907)}}).

### WebGL

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/27/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ More details in [this post](https://hacks.mozilla.org/2013/11/firefox-developer-
- The mathematical function {{jsxref("Global_Objects/Math/hypot", "Math.hypot()")}} has been implemented ({{bug("896264")}}).
- The {{jsxref("Operators/yield*", "yield*")}} expression is now implemented ({{bug(666396)}}).
- The `MapIterator`, `SetIterator` and `ArrayIterator` objects now match the specification ({{bug("881226")}}).
- [for..of](/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loops now expect the ES2015 standard [iterator protocol](/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) moving away from SpiderMonkey old iterator protocol using `StopIteration`.
- [for...of](/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loops now expect the ES2015 standard [iterator protocol](/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) moving away from SpiderMonkey old iterator protocol using `StopIteration`.
- {{jsxref("String.match")}} and {{jsxref("String.replace")}} now reset {{jsxref("RegExp.lastIndex")}} ({{bug(501739)}}).

### Interfaces/APIs/DOM
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/3.6/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ If you're an extension developer, you should start by reading [Updating extensio
- [Locale-aware collation of data is now supported by the Storage API](</en-US/docs/Storage#Collation_(sorting)>)
- : Gecko 1.9.2 added several new collation methods to provide optimized collation (sorting) of results using locale-aware techniques.
- [Properties on a statement can now be enumerated](/en-US/docs/mozIStorageStatementParams#enumeration_of_properties)
- : You can now use a [`for..in`](/en-US/docs/Web/JavaScript/Reference/Statements/for...in) enumeration to enumerate all the properties on a statement.
- : You can now use a [`for...in`](/en-US/docs/Web/JavaScript/Reference/Statements/for...in) enumeration to enumerate all the properties on a statement.
- mozIStorageStatement's getParameterIndex changed behavior between 3.5 and 3.6.
- : See {{bug(528166)}} for details.
- Asynchronously bind multiple sets of parameters and execute a statement.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function cStyles() {

## Example 7: Displaying Event Object Properties

This example uses DOM methods to display all the properties of the {{domxref("Window.load_event", "onload")}} {{domxref("event")}} object and their values in a table. It also shows a useful technique of using a for..in loop to iterate over the properties of an object to get their values.
This example uses DOM methods to display all the properties of the {{domxref("Window.load_event", "onload")}} {{domxref("event")}} object and their values in a table. It also shows a useful technique of using a [`for...in`](/en-US/docs/Web/JavaScript/Reference/Statements/for...in) loop to iterate over the properties of an object to get their values.

The properties of event objects differs greatly between browsers, the [WHATWG DOM Standard](https://dom.spec.whatwg.org) lists the standard properties, however many browsers have extended these greatly.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/nodelist/entries/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ node.appendChild(kid3);

const list = node.childNodes;

// Using for..of
// Using for...of
for (const entry of list.entries()) {
console.log(entry);
}
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/nodelist/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ for (let i = 0; i < myNodeList.length; i++) {
}
```

**Don't use [`for...in`](/en-US/docs/Web/JavaScript/Reference/Statements/for...in) to enumerate the items in `NodeList`s**, since they will _also_ enumerate its `length` and `item` properties and cause errors if your script assumes it only has to deal with {{domxref("element")}} objects. Also, `for..in` is not guaranteed to visit the properties in any particular order.
**Don't use [`for...in`](/en-US/docs/Web/JavaScript/Reference/Statements/for...in) to enumerate the items in `NodeList`s**, since they will _also_ enumerate its `length` and `item` properties and cause errors if your script assumes it only has to deal with {{domxref("element")}} objects. Also, `for...in` is not guaranteed to visit the properties in any particular order.

[`for...of`](/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loops loop over `NodeList` objects correctly:

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/nodelist/keys/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ node.appendChild(kid3);

let list = node.childNodes;

// Using for..of
// Using for...of
for (const key of list.keys()) {
console.log(key);
}
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/nodelist/values/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ node.appendChild(kid3);

const list = node.childNodes;

// Using for..of
// Using for...of
for (const value of list.values()) {
console.log(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Note that this is not the most efficient algorithm for all cases, but useful for
const SimplePropertyRetriever = {
getOwnEnumerables(obj) {
return this._getPropertyNames(obj, true, false, this._enumerable);
// Or could use for..in filtered with Object.hasOwn or just this: return Object.keys(obj);
// Or could use for...in filtered with Object.hasOwn or just this: return Object.keys(obj);
},
getOwnNonenumerables(obj) {
return this._getPropertyNames(obj, true, false, this._notEnumerable);
Expand All @@ -78,7 +78,7 @@ const SimplePropertyRetriever = {
},
getOwnAndPrototypeEnumerables(obj) {
return this._getPropertyNames(obj, true, true, this._enumerable);
// Or could use unfiltered for..in
// Or could use unfiltered for...in
},
getOwnAndPrototypeNonenumerables(obj) {
return this._getPropertyNames(obj, true, true, this._notEnumerable);
Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/javascript/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Overview: [Loops and iteration](/en-US/docs/Web/JavaScript/Guide/Loops_and_itera
- [`do...while`](/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#do...while_statement)
- [`continue`](/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#continue_statement)
- [`break`](/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#break_statement)
- [`for..in`](/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...in_statement)
- [`for..of`](/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...of_statement)
- [`for...in`](/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...in_statement)
- [`for...of`](/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...of_statement)

## Functions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tags:
---
{{jsSidebar("More")}}

> **Warning:** The legacy iterator protocol was a SpiderMonkey-specific feature, which is removed in Firefox 58+. For future-facing usages, consider using [for..of](/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loops and the [iterator protocol](/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
> **Warning:** The legacy iterator protocol was a SpiderMonkey-specific feature, which is removed in Firefox 58+. For future-facing usages, consider using [for...of](/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loops and the [iterator protocol](/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
## The deprecated Firefox-only iterator protocol

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ console.log(mapIter.next().value) // [1, "bar"]
console.log(mapIter.next().value) // [Object, "baz"]
```

### Using \[@@iterator]\() with for..of
### Using \[@@iterator]\() with for...of

```js
const myMap = new Map()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ myMap.get(otherNaN);
// "not a number"
```

### Iterating Map with for..of
### Iterating Map with for...of

Maps can be iterated using a `for..of` loop:
Maps can be iterated using a `for...of` loop:

```js
const myMap = new Map();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ console.log(setIter.next().value); // 1
console.log(setIter.next().value); // Object
```

### Using \[@@iterator]\() with for..of
### Using \[@@iterator]\() with for...of

```js
const mySet = new Set();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ console.log(strIter.next().value); // "A"
console.log(strIter.next().value); // "\uD835\uDC68"
```

### Using \[@@iterator]\() with for..of
### Using \[@@iterator]\() with for...of

```js
const str = 'A\uD835\uDC68B\uD835\uDC69C\uD835\uDC6A';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ for (const match of matches) {
// expected output: "Found football start=6 end=14."
// expected output: "Found foosball start=16 end=24."

// matches iterator is exhausted after the for..of iteration
// matches iterator is exhausted after the for...of iteration
// Call matchAll again to create a new iterator
Array.from(str.matchAll(regexp), (m) => m[0]);
// Array [ "football", "foosball" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The well-known **`Symbol.iterator`** symbol specifies the default iterator for a

## Description

Whenever an object needs to be iterated (such as at the beginning of a `for..of` loop), its `@@iterator` method is called with no arguments, and the returned **iterator** is used to obtain the values to be iterated.
Whenever an object needs to be iterated (such as at the beginning of a `for...of` loop), its `@@iterator` method is called with no arguments, and the returned **iterator** is used to obtain the values to be iterated.

Some built-in types have a default iteration behavior, while other types (such as {{jsxref("Object")}}) do not. The built-in types with a `@@iterator` method are:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ The array **iterator** function, which is the

```js
const arr = new Uint8Array([10, 20, 30, 40, 50]);
// your browser must support for..of loop
// and let-scoped variables in for loops
for (const n of arr) {
console.log(n);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ A new _array iterator_ object.
```js
const arr = new Uint8Array([10, 20, 30, 40, 50]);
const arrKeys = arr.keys();
// your browser must support for..of loop
// and let-scoped variables in for loops
for (const n of arrKeys) {
console.log(n);
}
Expand Down

0 comments on commit ba66c42

Please sign in to comment.