TypedArray Keys() JavaScript

The Javascript TypedArray Keys() method is used to retrieve an Array Iterator object with the keys of an array.

Syntax:

array.keys()

Parameters:
value: It represents the current element’s value.
index: It represents the index position of the current element.
arr: It represents the array.
thisValue: It represents this argument for the function.

Returns:
It returns an iterator object containing the keys as the index for each array element.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">   
var Jewels = ["DIAMOND","GOLD","PLATINUM","SILVER"];
result = Jewels.keys()  
document.write(result.next().value +"<br>");  
document.write(result.next().value +"<br>");
document.write(result.next().value +"<br>");
document.write(result.next().value);  
</script>
</body>
</html>

Example 2:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript"> 
var arr = new Uint8Array([34, 12, 45, 78, 12]);
var arrKey = arr.keys();
 
for (let key of arrKey) {
  document.write(key);
  document.write("</br>");
}
 
</script>
</body>
</html>