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 TypeScript Array Symbol.iterator Method P pankajbind Follow Improve Article Tags : JavaScript Web Technologies 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 String @@iterator Method String [@@iterator]( ) Method is used to make String iterable. [@@iterator]() returns an iterator object which iterates over all code points of String. String[@@iterator] is a Built-in Property of String. We can use this method by making a string iterator. We can make an iterator by calling the @@it 2 min read Lodash _.prototype[Symbol.iterator]() Method Lodash _.prototype[Symbol.iterator]() method of Sequence in lodash is used to permit the wrapper to be iterable. Syntax:_.prototype[Symbol.iterator]();Parameters: This method doesn't accept any parameter. Return Value: This method returns the lodash wrapper object. Example 1: In this example, we are 1 min read JavaScript Array values() Method JavaScript array.values() is an inbuilt method in JavaScript that is used to return a new array Iterator object that contains the values for each index in the array i.e., it prints all the elements of the array. Returns an iterator for accessing array values.Does not modify the original array.Works 5 min read JavaScript Map.prototype[@@iterator]() Method Map[@@iterator]( ) method is used to make Map iterable. Map[@@iterator]( ) method returns iterator object which iterates over all code points of Map. Map[@@iterator]( ) is built-in property of Map. We can use this method by creating Map iterator. We can make Map iterator by calling the @@iterator pr 2 min read Like