日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

幾個常用的Javascript函數(shù)

系統(tǒng) 2669 0


// *******************************************************
// replacements for unsupported array functions (because arrayname.push(var)
// and arrayname.pop() are not implemented in IE until version 5.5)
function thearrayisgood(thearray,i) {
? ?? ?? ?if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
? ?? ?? ?? ? return false;
? ?? ?? ?else
? ?? ?? ?? ? return true;
}

function getarraysize(thearray) {
// replacement for arrayname.length property
? ?? ???for (i = 0; i < thearray.length; i++) {
? ?? ?? ?? ?? ? if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
? ?? ?? ?? ?? ?? ?? ?? ?return i;
? ?? ?? ?? ?? ? }
? ?? ???return thearray.length;
}

function arraypush(thearray,value) {
// replacement for arrayname.push(value)
? ?? ???thearraysize = getarraysize(thearray);
? ?? ???thearray[thearraysize] = value;
? ?? ???return thearray[thearraysize];
}

function arraypop(thearray) {
// replacement for arrayname.pop()
? ?? ???thearraysize = getarraysize(thearray);
? ?? ???retval = thearray[thearraysize - 1];
? ?? ???delete thearray[thearraysize - 1];

??????? thearray.length--; <<==我加了這句,很關(guān)鍵,否則出錯
????????return retval;
}

// *******************************************************

另外給出網(wǎng)上幾個老外寫的

function Array_pop() {
? var response = this[this.length - 1]
? this.length--
? return response
? }

if (typeof(Array.prototype.pop) == "undefined") {
? Array.prototype.pop = Array_pop
? }

function Array_push() {
? var A_p = 0
? for (A_p = 0; A_p < arguments.length; A_p++) {
?? this[this.length] = arguments[A_p]
?? }
? return this.length
? }

if (typeof Array.prototype.push == "undefined") {
? Array.prototype.push = Array_push
? }



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=558849


幾個常用的Javascript函數(shù)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 凤翔县| 铜川市| 太仓市| 浮山县| 天全县| 英吉沙县| 日照市| 白玉县| 蕲春县| 信丰县| 山阳县| 沈阳市| 罗平县| 日土县| 鄂尔多斯市| 宣恩县| 二连浩特市| 永济市| 新密市| 陇南市| 石城县| 武安市| 茌平县| 鄂州市| 舟曲县| 乌兰浩特市| SHOW| 北票市| 古丈县| 天峻县| 鄱阳县| 绩溪县| 东海县| 漳平市| 穆棱市| 布拖县| 岳西县| 吴桥县| 新宁县| 舒城县| 普格县|