この記事はまだ日本語に翻訳されていません。MDN の翻訳はボランティアによって行われています。是非 MDN に登録し、私たちの力になって下さい。
This is an experimental technology, part of the Harmony (ECMAScript 6) proposal.
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future version of browsers as the spec changes.
Summary
The keys() method returns a new Array Iterator that contains the keys for each index in the array.
Syntax
arr.keys()
Examples
var arr = ["a","b","c"]; var eArr = arr.keys(); console.log(eArr.next().value); // 0 console.log(eArr.next().value); // 1 console.log(eArr.next().value); // 2
Specifications
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 6 (ECMA-262) The definition of 'Array.prototype.keys' in that specification. |
Draft | Initial definition. |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | (Yes)[1] | 28 (28) | Not supported | Not supported | Not supported |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | Not supported | Not supported | 28.0 (28) | Not supported | Not supported | Not supported |
[1] The feature is available behind a preference. Go to chrome://flags and activate the entry “Enable Experimental JavaScript”.