TypeScript Array Symbol.iterator Method Last Updated : 03 Sep, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In TypeScript the Symbol.iterator function plays a role, in allowing iteration over arrays using for...of loops and other iterator-based mechanisms. This built-in function eliminates the need, for definition when working with arrays simplifying the process of accessing elements. Syntax:const iterator: Iterator<T> = array[Symbol.iterator]();Parameter:None: No parameter is required.Return Value:It returns the iterable point that can be accessed in a for loop for getting values of that array.Example 1: We will iterate each element of an array by using a, for...of loop and see the working of Symbol.iterator Method. JavaScript // TypeScript code with annotations let numbers: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // Here we use Symbol.iterator to get the default iterator let iterator = numbers[Symbol.iterator](); for (let num of iterator) { console.log(num); } Output:12345678910Example 2: We are going to manually iterate using the next method and see the working of Symbol.iterator Method. JavaScript // TypeScript code with annotations let geeks: string[] = ['Pankaj', 'Ram', 'Shravan', 'Jeetu']; // Here we use Symbol.iterator to get the default iterator let iterator = geeks[Symbol.iterator](); // Manually iterating using the next method let output = iterator.next(); while (!output.done) { console.log(output.value); output = iterator.next(); } Output:PankajRamShravanJeetu Comment More infoAdvertise with us Next Article Iterator Interface In Java P pankajbind Follow Improve Article Tags : TypeScript Similar Reads TypeScript Array entries() Method The Array.prototype.entries() method in TypeScript returns a new array iterator object that contains the key/value pairs for each index in the array. This method is useful when you need to iterate over the key/value pairs in the array.Note: In TypeScript, the entries() method is not available direct 2 min read JavaScript typedArray.@@iterator The typedArray.@@iterator is an inbuilt property in JavaScript which is used to return the initial value of the given typedArray's element. Syntax: arr[Symbol.iterator]() Parameters: It does not accept any parameter because it is a property not a function. Return value: It returns the array iterator 1 min read Iterator Interface In Java Java Iterator Interface of java collections allows us to access elements of the collection and is used to iterate over the elements in the collection(Map, List or Set). It helps to easily retrieve the elements of a collection and perform operations on each element. Iterator is a universal iterator a 6 min read Iterators in C++ STL An iterator in C++ is a pointer-like object that points to an element of the STL container. They are generally used to loop through the contents of the STL container in C++. The main advantage of STL iterators is that they make the STL algorithms independent of the type of container used. We can jus 10 min read Iterator Method | JavaScript Design Pattern Iterator design pattern is a behavioral design pattern that provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation. It separates the responsibility of accessing and traversing the elements from the aggregate object. This pattern is wi 4 min read Iterable Interface in Java The Iterable interface was introduced in JDK 1.5. It belongs to java.lang package. In general, an object Implementing Iterable allows it to be iterated. An iterable interface allows an object to be the target of enhanced for loop(for-each loop). Definition of Iterable public interface Iterable<T 3 min read Like