Die keys() Methode gibt einen neues Array Iterator Objekt zurück, welches den Schlüssel für jeden Index des Arrays enthält.
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
arr.keys()
Rückgabewert
Ein neues Array iterator-Objekt.
Beispiele
Der Key Iterator ignoriert keine Lücken
var arr = ['a', , 'c']; var sparseKeys = Object.keys(arr); var denseKeys = [...arr.keys()]; console.log(sparseKeys); // ['0', '2'] console.log(denseKeys); // [0, 1, 2]
Spezifikationen
| Spezifikation | Status | Kommentar |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Array.prototype.keys' in dieser Spezifikation. |
Standard | Initiale Definition. |
| ECMAScript Latest Draft (ECMA-262) Die Definition von 'Array.prototype.keys' in dieser Spezifikation. |
Entwurf |
Browserkompatibilität
The compatibility table in 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.
Update compatibility data on GitHub
| Desktop | Mobile | Server | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Grundlegende Unterstützung | Chrome Vollständige Unterstützung 38 | Edge Vollständige Unterstützung Ja | Firefox Vollständige Unterstützung 28 | IE Keine Unterstützung Nein | Opera Vollständige Unterstützung 25 | Safari Vollständige Unterstützung 8 | WebView Android Vollständige Unterstützung Ja | Chrome Android Vollständige Unterstützung Ja | Edge Mobile Vollständige Unterstützung Ja | Firefox Android Vollständige Unterstützung 28 | Opera Android Vollständige Unterstützung Ja | Safari iOS Vollständige Unterstützung 8 | Samsung Internet Android Vollständige Unterstützung Ja | nodejs Vollständige Unterstützung 0.12 |
Legende
- Vollständige Unterstützung
- Vollständige Unterstützung
- Keine Unterstützung
- Keine Unterstützung
Siehe auch
Schlagwörter des Dokuments und Mitwirkende
Schlagwörter:
Mitwirkende an dieser Seite:
schlagi123,
Arlind
Zuletzt aktualisiert von:
schlagi123,