Metoda clear()
usuwa wszystkie elementy z obiektu Map
.
var map1 = new Map();
map1.set('bar', 'baz');
map1.set(1, 'foo');
console.log(map1.size);
// warto艣膰 zwracana: 2
map1.clear();
console.log(map1.size);
// warto艣膰 zwracana: 0
Sk艂adnia
myMap.clear();
Zwracana warto艣膰
Przyk艂ady
U偶ywanie metody clear
var myMap = new Map();
myMap.set('bar', 'baz');
myMap.set(1, 'foo');
myMap.size; // 2
myMap.has('bar'); // true
myMap.clear();
myMap.size; // 0
myMap.has('bar') // false
Specyfikacja
Specyfikacja | Status | Komentarz |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Map.prototype.clear' in that specification. |
Standard | Definicja pocz膮tkowa. |
ECMAScript (ECMA-262) The definition of 'Map.prototype.clear' in that specification. |
Living Standard |
Kompatybilno艣膰 z przegl膮darkami
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.