JavaScript Object Notation
来源:互联网 发布:c语言大于等于 编辑:程序博客网 时间:2024/05/17 00:58
Array.prototype.indexOf=function(obj)...{
var result=-1;
for(var i=0;i<this.length;i++)...{
if(this[i]==obj)...{
result=i;
break;
}
}
return result;
}
var arr = new Array(5);
arr[0]="hello";
arr[1]="welcome to china";
arr[2]="good";
alert(arr.indexOf("good"));
var result=-1;
for(var i=0;i<this.length;i++)...{
if(this[i]==obj)...{
result=i;
break;
}
}
return result;
}
var arr = new Array(5);
arr[0]="hello";
arr[1]="welcome to china";
arr[2]="good";
alert(arr.indexOf("good"));
Array.prototype.inArray = function (value) ...{
for (var i = 0; i < this.length; i++) ...{
if (this[i] === value) ...{
return true;
}
}
return false;
};
Array.prototype.max = function()...{
for (var i = 1, max = this[0]; i < this.length; i++)...{
if (max < this[i]) ...{
max = this[i];
}
return max;
};
Array.prototype.min = function()...{
for (var i = 1, min = this[0]; i < this.length; i++)...{
if (min > this[i]) ...{
min = this[i];
}
return min;
};
Array.prototype.indexOf = function(p_var)
...{
for (var i=0; i<this.length; i++)
...{
if (this[i] == p_var)
...{
return(i);
}
}
return(-1);
}
Array.prototype.exists = function(p_var) ...{return(this.indexOf(p_var) != -1);}
Array.prototype.queue = function(p_var) ...{this.push(p_var)}
Array.prototype.dequeue = function() ...{return(this.shift());}
Array.prototype.removeAt = function(p_iIndex) ...{return this.splice(p_iIndex, 1);}
Array.prototype.remove = function(o)
...{
var i = this.indexOf(o);
if (i>-1)
...{
this.splice(i,1);
}
return (i>-1);
}
Array.prototype.clear = function()
...{
var iLength = this.length;
for (var i=0; i < iLength; i++)
...{
this.shift();
}
}
Array.prototype.addArray = function(p_a)
...{
if (p_a)
...{
for (var i=0; i < p_a.length; i++)
...{
this.push(p_a[i]);
}
}
}
Array.prototype.Unique = function()
...{
var a = ...{}; for(var i=0; i<this.length; i++)
...{
if(typeof a[this[i]] == "undefined")
a[this[i]] = 1;
}
this.length = 0;
for(var i in a)
this[this.length] = i;
return this;
};
Array.prototype.indexOf = function(obj, fromIndex)
...{
if (fromIndex == null)
...{
fromIndex = 0;
}
else if (fromIndex < 0)
...{
fromIndex = Math.max(0, this.length + fromIndex);
}
for (var i = fromIndex; i < this.length; i++)
...{
if (this[i] === obj)
...{
return i;
}
}
return-1;
};
Array.prototype.lastIndexOf = function(obj, fromIndex)
...{
if (fromIndex == null)
...{
fromIndex = this.length - 1;
}
else if (fromIndex < 0)
...{
fromIndex=Math.max(0, this.length+fromIndex);
}
for (var i = fromIndex; i >= 0; i--)
...{
if (this[i] === obj)
...{
return i;
}
}
return -1;
};
Array.prototype.insertAt = function(o, i)
...{
this.splice(i, 0, o);
};
Array.prototype.insertBefore = function(o, o2)
...{
var i = this.indexOf(o2);
if (i == -1)
...{
this.push(o);
}
else
...{
this.splice(i, 0, o);
}
};
Array.prototype.remove = function(o)
...{
var i = this.indexOf(o);
if (i != -1)
...{
this.splice(i, 1);
}
};
Array.prototype.mm=function()
...{
var a=...{}, m=0, n="";
for(var i=0; i<this.length; i++)
a[this[i]]?++a[this[i]]:a[this[i]]=1;
for(i in a)...{m=Math.max(m, a[i]); if(m==a[i]) n=i;}
return ...{"variable": n, "times": m};
}
for (var i = 0; i < this.length; i++) ...{
if (this[i] === value) ...{
return true;
}
}
return false;
};
Array.prototype.max = function()...{
for (var i = 1, max = this[0]; i < this.length; i++)...{
if (max < this[i]) ...{
max = this[i];
}
return max;
};
Array.prototype.min = function()...{
for (var i = 1, min = this[0]; i < this.length; i++)...{
if (min > this[i]) ...{
min = this[i];
}
return min;
};
Array.prototype.indexOf = function(p_var)
...{
for (var i=0; i<this.length; i++)
...{
if (this[i] == p_var)
...{
return(i);
}
}
return(-1);
}
Array.prototype.exists = function(p_var) ...{return(this.indexOf(p_var) != -1);}
Array.prototype.queue = function(p_var) ...{this.push(p_var)}
Array.prototype.dequeue = function() ...{return(this.shift());}
Array.prototype.removeAt = function(p_iIndex) ...{return this.splice(p_iIndex, 1);}
Array.prototype.remove = function(o)
...{
var i = this.indexOf(o);
if (i>-1)
...{
this.splice(i,1);
}
return (i>-1);
}
Array.prototype.clear = function()
...{
var iLength = this.length;
for (var i=0; i < iLength; i++)
...{
this.shift();
}
}
Array.prototype.addArray = function(p_a)
...{
if (p_a)
...{
for (var i=0; i < p_a.length; i++)
...{
this.push(p_a[i]);
}
}
}
Array.prototype.Unique = function()
...{
var a = ...{}; for(var i=0; i<this.length; i++)
...{
if(typeof a[this[i]] == "undefined")
a[this[i]] = 1;
}
this.length = 0;
for(var i in a)
this[this.length] = i;
return this;
};
Array.prototype.indexOf = function(obj, fromIndex)
...{
if (fromIndex == null)
...{
fromIndex = 0;
}
else if (fromIndex < 0)
...{
fromIndex = Math.max(0, this.length + fromIndex);
}
for (var i = fromIndex; i < this.length; i++)
...{
if (this[i] === obj)
...{
return i;
}
}
return-1;
};
Array.prototype.lastIndexOf = function(obj, fromIndex)
...{
if (fromIndex == null)
...{
fromIndex = this.length - 1;
}
else if (fromIndex < 0)
...{
fromIndex=Math.max(0, this.length+fromIndex);
}
for (var i = fromIndex; i >= 0; i--)
...{
if (this[i] === obj)
...{
return i;
}
}
return -1;
};
Array.prototype.insertAt = function(o, i)
...{
this.splice(i, 0, o);
};
Array.prototype.insertBefore = function(o, o2)
...{
var i = this.indexOf(o2);
if (i == -1)
...{
this.push(o);
}
else
...{
this.splice(i, 0, o);
}
};
Array.prototype.remove = function(o)
...{
var i = this.indexOf(o);
if (i != -1)
...{
this.splice(i, 1);
}
};
Array.prototype.mm=function()
...{
var a=...{}, m=0, n="";
for(var i=0; i<this.length; i++)
a[this[i]]?++a[this[i]]:a[this[i]]=1;
for(i in a)...{m=Math.max(m, a[i]); if(m==a[i]) n=i;}
return ...{"variable": n, "times": m};
}
- JavaScript Object Notation
- JavaScript Object Notation
- JSON(JavaScript Object Notation)
- JSON(JavaScript Object Notation)
- JavaScript Object Notation[JSON]
- JSON(JavaScript Object Notation)
- JavaScript Object Notation
- JSON(JavaScript Object Notation)
- JSON(JavaScript Object Notation)
- JSON: javascript object notation
- JSON (JavaScript Object Notation)
- JSON(JavaScript Object Notation)
- JavaScript Object Notation(json)
- JSON (JavaScript Object Notation)
- 精通JSON (JavaScript Object Notation)
- 精通JSON (JavaScript Object Notation)
- 学习 JSON ( JavaScript Object Notation )
- SON(JavaScript Object Notation)学习
- eclipse 不能正常启动
- Subversion 十分钟上手
- 使用汇编取得PE文件导入的DLL名称和函数名称
- 都是base惹的祸
- 建立智能客户端应用的开发路标
- JavaScript Object Notation
- 人的分类:富与穷
- 易出错的地方
- 在一个WINDOWS的应用程序中嵌入IE浏览器
- MySQL服务维护笔记
- 汇集DOMINO中的内置域
- 虚拟软件市场大有可为 微软VMware发生碰撞
- 2007年3月东北微软技术活动预告
- AJAX技术汇总