Typed Array values()
Example
// Create a Typed Array
const myArr = Int16Array.from([10,15,20,25,30]);
// Create an Iterator
const list = myArr.values();
Try it Yourself »
More Examples Below !
Description
The values()
method returns an iterator object with the values of a typed array.
The values()
method does not change the original array.
Typed Array Iteration Methods:
Syntax
typed-array.values()
Parameters
NONE |
Return Value
Type | Description |
Iterator | An Iterator object containing the values of the typed array. |
More Examples
Example
Iterate directly over the Iterator:
// Create a Typed Array
const myArr = Int16Array.from([10,15,20,25,30]);
// List the Values
let text = "";
for (let x of myArr.values()) {
text += x + "<br>";
}
Try it Yourself »
Example
Use the built in Object.values() method:
// Create a Typed Array
const myArr = Int16Array.from([10,15,20,25,30]);
// List the Values
let text = "";
for (let x of Object.values(fruits)) {
text += x + "<br>";
}
Try it Yourself »
JavaScript Typed Arrays
Browser Support
typed-array.values()
is an ECMAScript6 (ES6 2015) feature.
JavaScript 2015 is fully supported in all modern browsers since June 2017:
Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 |