国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
JScript Array對(duì)象的幾個(gè)原型方法

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};
}

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
JavaScript數(shù)組中的九類(lèi)方法
JS判斷元素是否在數(shù)組內(nèi)
Extending JavaScript Objects and Classes
數(shù)組中是否存在某個(gè)值
刪除數(shù)組中重復(fù)項(xiàng)(uniq)
JavaScript數(shù)組去重(12種方法,史上最全)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服