Home >Web Front-end >JS Tutorial >javascript atEnd 方法

javascript atEnd 方法

WBOY
WBOYOriginal
2016-06-01 09:54:421492browse

atEnd 方法返回一个 Boolean 值,指明枚举算子是否位于集合的末尾。

基本语法

<code class="language-javascript">myEnum.atEnd()</code>

必选项 myEnum 参数是任意 Enumerator 对象。

说明

如果当前项是集合中的最后一个,或者集合为空,或者当前项没有定义,那么 atEnd 方法将返回 true 。否则返回 false 。

实例

在下面的代码中,使用了 atEnd 方法来决定是否到达了一个驱动器列表的末尾:

<code class="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 = "[驱动器未就绪]";
      s +=   n + "<br>";
   }
   return(s);
}
</code>

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn