Typed array iterators
The [Symbol.iterator]() method of TypedArray instances implements the iterable protocol and allows typed arrays to be consumed by most syntaxes expecting iterables, such as the spread syntax and for...of loops. It returns an array iterator object that yields the value of each index in the typed array.
The initial value of this property is the same function object as the initial value of the TypedArray.prototype.values property.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 38 | 12 | 36 | 10 | 38 | 10 | |
| Built-in object | ||||||
| The entries() method of TypedArray instances returns a new array iterator object that contains the key/value pairs for each index in the typed array. This method has the same algorithm as Array.prototype.entries(). | 45 | 12 | 37 | 10 | 45 | 10 |
| The keys() method of TypedArray instances returns a new array iterator object that contains the keys for each index in the typed array. This method has the same algorithm as Array.prototype.keys(). | 38 | 12 | 37 | 10 | 38 | 10 |
| The values() method of TypedArray instances returns a new array iterator object that iterates the value of each item in the typed array. This method has the same algorithm as Array.prototype.values(). | 38 | 12 | 37 | 10 | 38 | 10 |
- This feature was removed in a later browser version (36)
- This feature was removed in a later browser version (27)
- Previously available under a different name: @@iterator (27)
- A placeholder property named `@@iterator` is used.
- Previously available under a different name: iterator (17)
- A placeholder property named `iterator` is used.
Syntax
// Typed array iterators example
// See MDN Web Docs for details Live demo
Use cases
-
Using Typed array iterators
The [Symbol.
Cautions
- No specific concerns. Stable across all major browsers.
Accessibility
- When updating the DOM dynamically, announce important changes to assistive technology with aria-live regions.