JavaScript - indexOf Iterator Via A Generator

This is an example of creating and using a generator function with JavaScript 1.7 in FireFox. This example only works in FireFox 2 or higher. This basically allows you to enter a message and a substring that appears in the message and then you can click the button to display all of the indices of the substring in the message. Once you are done, move your mouse to the top-right of the window and click on "Edit in JSBin.com" to view the code.










FYI, the code used to define the indexOfIter function is as follows:

This example was written by Chris West.