87,922
社区成员
发帖
与我相关
我的任务
分享
//查找数组中是否有某元素的值
Array.prototype.indexOf=function(obj){
var result=-1;
for(var i=0;i<this.length;i++)
{
if(obj==this[i])
{
i=result;
break;
}
}
return result;
}
//判断数组中是否包含某元素
Array.prototype.contains=function(obj){
return (this.indexOf(obj)>=0);
}
//删除所有数组元素
Array.prototype.clear=function(){
this.length=0;
}
//根据开始索引移除指定数组中的元素 index为开始的索引
Array.prototype.removeAt=function(index){
this.splice(index,1);
}
//移除数组某个元素
Array.prototype.Remove=function(obj)
{
if(this.indexOf(obj)>=0)
{
this.removeAt(this.indexOf(obj));
}
}
//在数组指定索引处插入元素的值
Array.prototype.insertAt=function(index,obj){
this.splice(index,0,obj);
}
//" 1234 ".trim();
var testRichStr = new RichString(" 1234 ");
alert(testRichStr.trim());