Enumerator.atEnd()

JScript3.0+Syntax

							enumeratorobj.atEnd()

Description

The atEnd() method of the Enumerator object returns true if the enumerator is pointing to the last element in the collection; otherwise, it returns false. True is also returned if the collection is empty or undefined.

Example

The atEnd() method is used in Listing 9.42 to determine when to stop looping through the for loop.

Listing 9.42 Stop Looping with the atEnd() Method
 <html> <H1>Drive Letters and drive types:</H1> <script language="JScript"> <!-- Hide //Create enumerator object var fileSysObj = new ActiveXObject("Scripting.FileSystemObject"); var en = new Enumerator(fileSysObj.Drives); //Display drive letter and type for each drive. for (;!en.atEnd();en.moveNext()) ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.