JavaScript TypedArray values() Method

The values method in JavaScript serves the purpose of establishing the value of the elements contained within an array.

Syntax:

Example

array.values()

Parameters:

No parameters

Return value:

Index value

Browser Support:

Chrome Yes
Safari Yes
Firefox Yes
Opera Yes

Example 1

JavaScript TypedArray values Method.

Example

<script>

//JavaScript to illustrate types() method

 var A = new Uint8Array([ 1,3,4,5,6,7,8,9 ]);

  // Calling array.values() method

   var pyVisualizer = A.values();

   // Printing value of index 0

   document.write(pyVisualizer.next().value);

    // expected output:1

</script>

Output:

Example 2

JavaScript TypedArray values Method.

Example

<script>

 //JavaScript to illustrate types() method 

var A = new Uint8Array([ 1,3,4,5,6,7,8,9 ]);

   // Calling array.values() method

   var pyVisualizer = A.values();

// shift index to the 1 

iterator.next();

   // Printing the value of index 1

   document.write(pyVisualizer.next().value);

    // expected output:3

</script>

Output:

Example 3

JavaScript TypedArray values Method.

Example

<script>

 //JavaScript to illustrate types() method

 var A = new Uint8Array([ 1,3,4,5,6,7,8,9 ]);

   // Calling array.values() method

   var pyVisualizer = A.values();

       iterator.next()

       iterator.next()

       iterator.next()

       iterator.next()

       iterator.next()

       iterator.next()

       iterator.next()

       iterator.next()

   document.write(pyVisualizer.next().value);

    // expected output:undefined

</script>

Output:

Output

Undefined

Input Required

This code uses input(). Please provide values below: