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

 Live Demo

<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

Updated on: 25-Jun-2020

34 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements