(SM) Support Tip: How to extract elements from a delimited list using JavaScript

The following javascript code helps to separate each of the elements from a list separated by semicolon.
For example, the eventout records may contain a list of the emails to which a notification will be sent

var count=1;
var posdelimiter=0;
var oneemail="";
while (thelist.length!=0)
        posdelimiter=thelist.indexOf(";");//This delimiter can be changed to any character that separate the list, in this case a semicolon
        // Section to add any code where each of the values from the list will be used. In this case, olny print each value
        print("element number " count " from the list is: " oneemail);
        thelist=thelist.substring(posdelimiter 1,thelist.length);
        count ;