看板 Ajax 關於我們 聯絡資訊
這是從cookie的網頁中截取的一段, 小女子我看不太懂是什麼意思Q_Q prototype.splice怎麼用? 整段下來又是做什麼用的呢?是刪除嗎? (↑因為我在其它地方找不到刪除的功能...QQ) if (!Array.prototype.splice) { function array_splice(ind,cnt) { if (arguments.length == 0) return ind; if (typeof ind != "number") ind = 0; if (ind < 0) ind = Math.max(0,this.length + ind); if (ind > this.length) { if (arguments.length > 2) ind = this.length; else return []; } if (arguments.length < 2) cnt = this.length-ind; cnt = (typeof cnt == "number") ? Math.max(0,cnt) : 0; removeArray = this.slice(ind,ind+cnt); endArray = this.slice(ind+cnt); this.length = ind; for (var i = 2; i < arguments.length; i++) { this[this.length] = arguments[i]; } for(var i = 0; i < endArray.length; i++) { this[this.length] = endArray[i]; } return removeArray; } Array.prototype.splice = array_splice; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 125.230.174.215
braveht:檢查Array有沒有支援splice這個方法 沒有的話自己寫一個 08/08 13:01
annypeter:我查過網路,應該是有,但是沒寫怎麼用 08/08 13:27
WanCW:http://0rz.tw/202Vp # mozilla 上的解說與範例 08/08 15:16