当前位置:Gxlcms > JavaScript > javascriptatEnd方法

javascriptatEnd方法

时间:2021-07-01 10:21:17 帮助过:31人阅读

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

基本语法

myEnum.atEnd()

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

说明

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

实例

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

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 + "
"; } return(s); }

人气教程排行