Die clear()
Methode entfernt alle Elemente von einem Map
Objekt.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
myMap.clear();
Rückgabewert
Beispiele
Einsatz der clear
Methode
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
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Map.prototype.clear' in dieser Spezifikation. |
Standard | Initiale Definition. |
ECMAScript (ECMA-262) Die Definition von 'Map.prototype.clear' in dieser Spezifikation. |
Lebender Standard |
Browserkompatibilität
BCD tables only load in the browser