JavaScript tutorial:
item method

 

Applies to: Enumerator Object

The item method is use to ge the current item in the collection.

Syntax

myEnum.item( )

The myEnum argument is any Enumerator object.

Return

The item method returns the current item. If the collection is empty or the current item is undefined, it returns undefined.

Example

In following code, the item method is used to return a member of the Drives collection:

<HTML>
<HEAD>
<SCRIPT LANGUAGE= JavaScript>
function ShowDriveList()
{
var fso, s, n, e, x;
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.Drives);
s = "";
for (; !e.atEnd(); e.moveNext())
{
x = e.item();
s = s + x.DriveLetter;
s += " - ";
if (x.DriveType == 3)
n = x.ShareName;
else if (x.IsReady)
n = x.VolumeName;
else
n = "[Drive not ready]";
s += n + "<br>";
}
return(s);
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE= JavaScript>
document.write(ShowDriveList());
</SCRIPT>
</BODY>
</HTML>

To run the code above, paste it into JavaScript Editor, and go to View, Internal Page Viewer or press F5.

See Also: atEnd Method, moveFirst Method, moveNext Method