Saturday, October 25, 2025
HomeLanguagesJavascriptJavaScript typedArray.keys() Method

JavaScript typedArray.keys() Method

The typedArray.keys() is an inbuilt function in JavaScript which is used to return a new array iterator containing the keys for each index of the elements of the given typedArray. 

Syntax:

typedArray.keys()

Parameter: This function does not accept anything as parameter. 

Return value: It returns a new array iterator object containing the keys for each index of the elements of the given typedArray. 

Example: JavaScript code to show the working of this function.

javascript




// Creating some typedArrays
const A = new Uint8Array([1, 2, 3, 4, 5]);
const B = new Uint8Array([5, 10, 15, 20]);
const C = new Uint8Array([0, 2, 4, 6, ,8, 10]);
const D = new Uint8Array([1, 3, 5, 7, 9]);
  
// Calling keys() function
a = A.keys()
console.log(a.next().value);
  
b = B.keys()
b.next();
console.log(b.next().value);
  
c = C.keys()
c.next();
c.next();
console.log(c.next().value);
  
d = D.keys()
d.next();
d.next();
d.next();
console.log(d.next().value);


Output:

0
1
2
3
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS