Computer >> Computer tutorials >  >> Programming >> Javascript

TypedArray.values() function in JavaScript


The values() function of the TypedArray returns an iterator object which holds the values of the typed array. The next() method returns the next element in the iterator object.

Syntax

Its Syntax is as follows

typedArray.values()

Example

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var typedArray = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]);
      var iterator = typedArray.values();
      document.write("Contents of the typed array: ");
      for(i=0; i<typedArray.length; i++) {
         document.writeln(iterator.next().value);
      }
   </script>
</body>
</html>

Output

Contents of the typed array: 11 5 13 4 15 3 17 2 19 8