Export (0) Print
Expand All

atEnd Method (JavaScript)

Returns a Boolean value indicating if the enumerator is at the end of the collection.

myEnum.atEnd()

The required myEnum reference is any Enumerator object.

The atEnd method returns true if the current item is the last one in the collection, the collection is empty, or the current item is undefined. Otherwise, it returns false.

In following code, the atEnd method is used to determine if the end of a list of drives has been reached:

function ShowDrives()
{
    var s = "";
    var bytesPerGB = 1024 * 1024 * 1024;

    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var e = new Enumerator(fso.Drives);

    e.moveFirst();
    while (e.atEnd() == false)
    {
        var drv = e.item();

        s += drv.Path + " - ";

        if (drv.IsReady)
        {
            var freeGB = drv.FreeSpace / bytesPerGB;
            var totalGB = drv.TotalSize / bytesPerGB;

            s += freeGB.toFixed(3) + " GB free of ";
            s += totalGB.toFixed(3) + " GB";
        }
        else
        {
            s += "Not Ready";
        }

        s += "<br />";

        e.moveNext();
    }
    return(s);
}

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Applies To: Enumerator Object (JavaScript)

Community Additions

Show:
© 2014 Microsoft