-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
43 lines (28 loc) · 837 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
title: Map.prototype.size
slug: Web/JavaScript/Reference/Global_Objects/Map/size
page-type: javascript-instance-accessor-property
browser-compat: javascript.builtins.Map.size
---
{{JSRef}}
The **`size`** accessor property of {{jsxref("Map")}} instances returns the number of elements in this map.
{{EmbedInteractiveExample("pages/js/map-prototype-size.html")}}
## Description
The value of `size` is an integer representing how many entries the `Map` object
has. A set accessor function for `size` is `undefined`; you can not change this
property.
## Examples
### Using size
```js
const myMap = new Map();
myMap.set("a", "alpha");
myMap.set("b", "beta");
myMap.set("g", "gamma");
console.log(myMap.size); // 3
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{jsxref("Map")}}