首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > ASP.NET > MsAjax Lib-> Array.indexOf 函数
【标  题】:MsAjax Lib-> Array.indexOf 函数
【关键字】:MsAjax,Lib-,Array.indexOf
【来  源】:http://blog.csdn.net/chsword/archive/2007/02/25/1514186.aspx

MsAjax Lib-> Array.indexOf 函数

Array.indexOf 函数

返回 Array 中某个值第一个匹配项的索引。 静态函数,使用无需实例化。

语法

var indexVar = Array.indexOf(array, item, start);

参数

参数

说明

array

要查找的数组

item

要查找的元素项目

startIndex

(可行参数)搜索的起始索引。

返回值

如找到则返回第一个匹配元素 item 在Array中的索引, 否则返回该数组的下限减1(一般为-1).

在Firefox浏览器中使用设置为undefineditem 来调用该函数, 返回第一个undefined的索引. 其它浏览器在该情况下返回 -1.

备注

使用 indexOf 函数查找Array 中某个值第一个匹配项的索引。

下面示例展示如何使用indexOf 函数来得到一个item的索引值. 返回第一次出现的 item的索引. 你可以发现再次调用函数查找含有 item 有数组时可以采用 开始索引值的不同来查找下一个匹配项的索引.

JavaScript

var a = ['red', 'blue', 'green', 'blue'];
var myFirstIndex = Array.indexOf(a, "blue");
// 返回结果: "1"
document.write("myFirstIndex: ",myFirstIndex,"</p>");
var mySecondIndex = Array.indexOf(a, "blue", (myFirstIndex + 1) );
// 返回结果: "3"
document.write("mySecondIndex: ", mySecondIndex,"</p>");

 
MsAjax Lib-> Array.insert 函数:【上一篇】
MsAjax Lib-> Array.forEach 函数:【下一篇】
【相关文章】
  • MsAjax Lib-> Array.insert 函数
  • MsAjax Lib-> Array.remove 函数
  • MsAjax Lib-> Array.removeAt 函数
  • MsAjax Lib-> Boolean 类型扩展
  • MsAjax Lib-> Boolean.parse 函数
  • MsAjax Lib-> Date.format 函数
  • MsAjax Lib-> Date.localeFormat 函数
  • MsAjax Lib-> Date.parseLocale 函数
  • MsAjax Lib-> Date.parseInvariant 函数
  • MsAjax Lib-> Date 类型扩展
  • 【随机文章】
  • cmd的终极防守
  • 用ASP开发一个在线考试程序(六)
  • Windows SharePoint Services 中文网站模板
  • Apache服务器配置全攻略(七)
  • UNIX系统终极安装----AIX篇
  • 网站设计八步骤
  • linux指令大全(1)
  • java程序的第一篇
  • .NET中绑定枚举类型
  • 在 C# 中处理结构内的数组
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.