Skip to content

Commit a565291

Browse files
authored
h2m (215f755) for web/javascript/ref/glob/map (#6194)
1 parent 8c6e534 commit a565291

File tree

30 files changed

+1405
-1374
lines changed

30 files changed

+1405
-1374
lines changed

files/en-us/web/javascript/reference/global_objects/map/@@iterator/index.html

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: Map.prototype[@@iterator]()
3+
slug: Web/JavaScript/Reference/Global_Objects/Map/@@iterator
4+
tags:
5+
- ECMAScript 2015
6+
- Iterator
7+
- JavaScript
8+
- Map
9+
- Method
10+
- Prototype
11+
- Reference
12+
browser-compat: javascript.builtins.Map.@@iterator
13+
---
14+
{{JSRef}}
15+
16+
<p class="seoSummary">The initial value of the <strong><code>@@iterator</code></strong>
17+
property is the same function object as the initial value of the
18+
{{jsxref("Map.prototype.entries()", "entries")}} method.</p>
19+
20+
{{EmbedInteractiveExample("pages/js/map-prototype-@@iterator.html")}}
21+
22+
## Syntax
23+
24+
```js
25+
myMap[Symbol.iterator]
26+
```
27+
28+
### Return value
29+
30+
The map **iterator** function, which is the
31+
{{jsxref("Map.prototype.entries()", "entries()")}} function by
32+
default.
33+
34+
## Examples
35+
36+
### Using \[@@iterator]\()
37+
38+
```js
39+
const myMap = new Map()
40+
myMap.set('0', 'foo')
41+
myMap.set(1, 'bar')
42+
myMap.set({}, 'baz')
43+
44+
const mapIter = myMap[Symbol.iterator]()
45+
46+
console.log(mapIter.next().value) // ["0", "foo"]
47+
console.log(mapIter.next().value) // [1, "bar"]
48+
console.log(mapIter.next().value) // [Object, "baz"]
49+
```
50+
51+
### Using \[@@iterator]\() with for..of
52+
53+
```js
54+
const myMap = new Map()
55+
myMap.set('0', 'foo')
56+
myMap.set(1, 'bar')
57+
myMap.set({}, 'baz')
58+
59+
for (const entry of myMap) {
60+
console.log(entry)
61+
}
62+
// ["0", "foo"]
63+
// [1, "bar"]
64+
// [{}, "baz"]
65+
66+
for (const [key, value] of myMap) {
67+
console.log(`${key}: ${value}`)
68+
}
69+
// 0: foo
70+
// 1: bar
71+
// [Object]: baz
72+
```
73+
74+
## Specifications
75+
76+
{{Specifications}}
77+
78+
## Browser compatibility
79+
80+
{{Compat}}
81+
82+
## See also
83+
84+
- {{jsxref("Map.prototype.entries()")}}
85+
- {{jsxref("Map.prototype.keys()")}}
86+
- {{jsxref("Map.prototype.values()")}}

files/en-us/web/javascript/reference/global_objects/map/@@species/index.html

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: get Map[@@species]
3+
slug: Web/JavaScript/Reference/Global_Objects/Map/@@species
4+
tags:
5+
- ECMAScript 2015
6+
- JavaScript
7+
- Map
8+
- Property
9+
browser-compat: javascript.builtins.Map.@@species
10+
---
11+
{{JSRef}}
12+
13+
The **`Map[@@species]`** accessor property returns the `Map` constructor.
14+
15+
## Description
16+
17+
The species accessor property returns the default constructor for `Map` objects.
18+
Subclass constructors may over-ride it to change the constructor assignment.
19+
20+
## Examples
21+
22+
### Species in ordinary objects
23+
24+
The species property returns the default constructor function, which is the
25+
`Map` constructor for `Map` objects:
26+
27+
```js
28+
Map[Symbol.species]; // function Map()
29+
```
30+
31+
### Species in derived objects
32+
33+
In a derived collection object (e.g. your custom map `MyMap`), the `MyMap`
34+
species is the `MyMap` constructor. However, you might want to overwrite this,
35+
in order to return parent `Map` objects in your derived class methods:
36+
37+
```js
38+
class MyMap extends Map {
39+
// Overwrite MyMap species to the parent Map constructor
40+
static get [Symbol.species]() { return Map; }
41+
}
42+
```
43+
44+
## Specifications
45+
46+
{{Specifications}}
47+
48+
## Browser compatibility
49+
50+
{{Compat}}
51+
52+
## See also
53+
54+
- {{jsxref("Map")}}
55+
- {{jsxref("Symbol.species")}}

files/en-us/web/javascript/reference/global_objects/map/@@tostringtag/index.html

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Map.prototype[@@toStringTag]
3+
slug: Web/JavaScript/Reference/Global_Objects/Map/@@toStringTag
4+
tags:
5+
- ECMAScript 2015
6+
- JavaScript
7+
- Map
8+
- Property
9+
- Prototype
10+
- Reference
11+
browser-compat: javascript.builtins.Map.@@toStringTag
12+
---
13+
{{JSRef}}
14+
15+
The **`Map[@@toStringTag]`** property has an initial value of "Map".
16+
17+
{{EmbedInteractiveExample("pages/js/map-prototype-@@tostringtag.html","shorter")}}{{js_property_attributes(0,0,1)}}
18+
19+
## Syntax
20+
21+
```js
22+
Map[Symbol.toStringTag]
23+
```
24+
25+
## Examples
26+
27+
### Using toStringTag
28+
29+
```js
30+
Object.prototype.toString.call(new Map()) // "[object Map]"
31+
```
32+
33+
## Specifications
34+
35+
{{Specifications}}
36+
37+
## Browser compatibility
38+
39+
{{Compat}}
40+
41+
## See also
42+
43+
- {{jsxref("Symbol.toStringTag")}}

0 commit comments

Comments
 (0)