Enables enumeration of items in a collection.
enumObj = new Enumerator([collection])
Collections differ from arrays in that the members of a collection are not directly accessible. Instead of using indexes, as you would with arrays, you can only move the current item pointer to the first or next element of a collection.
The Enumerator object provides a way to access any member of a collection and behaves similarly to the For...Each statement in VBScript.
The following code shows the usage of the Enumerator object:
function ShowDriveList(){ var fso, s, n, e, x; //Declare variables. fso = new ActiveXObject("Scripting.FileSystemObject"); e = newEnumerator(
fso.Drives)
; //Create Enumerator on Drives. s = ""; for (;!e.atEnd();e.moveNext()) //Enumerate drives collection. { x = e.item(); s = s + x.DriveLetter; s += " - "; if (x.DriveType == 3) //See if network drive. n = x.ShareName; //Get share name else if (x.IsReady) //See if drive is ready. n = x.VolumeName; //Get volume name. else n = "[Drive not ready]"; s += n + "<br>"; } return(s); //Return active drive list. }
The Enumerator object has no properties.
atEnd Method | item Method | moveFirst Method | moveNext Method