js搜索指定的Object,并返回第一个匹配项从零开始的索引
来源:网络 作者:佚名 点击:
次时间:2017-08-07 22:15
[摘要] /**方法:Array.IndexOf(obj)*功能:搜索指定的Object,并返回第一个匹配项从零开始的索引*参数:要查找的Object对象*返回:找到返回该元素在数...
-
-
-
-
-
-
- Array.prototype.IndexOf = function(obj) {
- if (null == obj) {
- return;
- } {
- for (var i = 0, n = 0; i < this.length; i++) {
- if (this[i] == obj) {
- return i;
- }
- }
- }
-
- return -1;
- }
|
------分隔线----------------------------