JavaScript Tutorial/MS JScript/Enumerator

Материал из Web эксперт
Перейти к: навигация, поиск

Enumerator

Syntax



   <source lang="javascript">

var variable = new Enumerator(collection)</source>


The Enumerator object provides access to items in a collection by allowing iteration through a collection.

Unlike arrays, enumerators can not access a specific position.

Methods Associated with Enumerator Object

Method Description atEnd() Determines if Enumerator is at the end of the collection item() Returns the current item in the collection moveFirst() Resets the Enumerator to the first item in the collection moveNext() Moves Enumerator to the next item in the collection

Enumerator.atEnd()

The atEnd() method 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.



   <source lang="javascript">

<html>

Drive Letters and drive types:

   <script language="JScript">
   
   </script>
   </html></source>
   
  

Enumerator.item()

The item() method returns the element that the enumerator is pointing to in the collection. If the collection is empty or undefined, undefined is returned.



   <source lang="javascript">

<html>

Drive Letters and drive types:

   <script language="JScript">
   
   </script>
   </html></source>
   
  

Enumerator.moveFirst()

The moveFirst() method moves the enumerator to the beginning of the collection. If the collection is empty or undefined, undefined is returned.



   <source lang="javascript">

<html>

Drive Letters and drive types:

   <script language="JScript">
   
   </script>
   </html></source>
   
  

Enumerator.moveNext()

The moveNext() method moves the enumerator to the next element in the collection. If the collection is empty, undefined is returned.



   <source lang="javascript">

<html>

Drive Letters and drive types:

   <script language="JScript">
   
   </script>
   </html></source>