GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — Javascript String @@iterator Method - GeeksforGeeks Javascript String @@iterator MethodLast Updated : 23 Jul, 2025 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 @@iterator property of String. In place of @@iterator, we use Symbol.iterator constant. Syntax: // Test String var str ="String"; // iterator to String var iter = str[Symbol.iterator](); We can get the iterator object with next(). It returns the object with the key value and is done. The value key holds a real iterating value string and the done key holds true or false if iteration finishes it keeps true if not then false. We can get the value of the object by str.value and done by str.done. Example 1: Below is the code that illustrates the use of the above approach.
"G" false "F" false "G" false We can use the @@iterator method without assigning an iterator by using for — of loop to iterate the over-collection of data in using @@iterator method. On each iteration for — of loop call _next().value to iterate in the collection. Example 2: Below is the code that illustrates the use of the above approach.
"G" "F" "G" Iterating by for-of loop : "G" "F" "G" Supported Browsers:
We have a complete list of Javascript string methods, to check those please go through this Javascript String Complete reference article. Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |