splice | BrE splʌɪs, AmE splaɪs |
A.transitive verb
①(join by interweaving the strands) 絞接 jiǎojiē ‹rope(s)›
▸ to splice sth to sth
把某物與某物捻接起來
▸ to splice two things together
絞接兩樣東西
▸ to get spliced
British informal 結婚
②(join at the ends) 粘接 zhānjiē ‹pieces of timber, film, tape›
▸ to splice two things together
把兩樣東西粘接起來slice B.transitive verb
①(cut into slices) 把…切片 bǎ… qiē piàn ‹bread›
▸ to slice sth thin or thinly/thick or thickly
把某物切成薄片/厚片
▸ to slice sth in two or half
把某物切成兩半
▸ thinly or thin-sliced/thickly or thick-sliced
切成薄片/厚片的
▸ sliced meat/cucumber
肉片/黃瓜片
②(cut from whole) 切下 qiēxia
▸ to slice sth off or from sth;
把某物從某物上切下來
▸ to slice two seconds off the record
把紀錄縮短兩秒鐘
▸ to slice £300 off the budget
把預算減小300英鎊
③(cut through) «knife» 劃破 huápò ‹flesh, cloth›; «fin, wing» 劃過 huáguo ‹water, air›
▸ to slice a leg/an arm to the bone
把腿/胳膊劃破深及骨頭
▸ to slice the water
«ship, bow» 破浪前進
④Sport 削 xiāo ‹ball›
▸ to slice a ball or shot into/to sth
(in tennis) 把球斜切打進/打到某處
▸ to slice a catch to the wicketkeeper
(in cricket) 把球斜切擊出給捕手接住
▸ to slice a corner into the net
(in football) 使角球斜切進網數組
參數1:索引,必需。一個整數,指定添加/刪除項目的位置,使用負值指定數組末尾的位置。code
參數2:可選。要刪除的項目數。若是設置爲0(零),則不會刪除任何項目。若是沒有經過,將刪除提供的索引中的全部項目。orm
參數3 ... n:可選。要添加到數組的新項目。對象
var array=[1,2,3,4,5]; console.log(array.splice(2)); //從index=2的位置截斷,後面的拋棄 // 顯示 [3, 4, 5], 被刪除的項目以新數組形式返回. console.log(array); // 顯示 [1, 2], 原數組被修改. var array2=[6,7,8,9,0]; console.log(array2.splice(2,1)); // 從index=2的位置截斷,後面的拋棄一個 // 顯示 [8] console.log(array2.splice(2,0)); //顯示空數組 [] , 沒有項目被刪除. console.log(array2); // 顯示 [6,7,9,0] var array3=[11,12,13,14,15]; console.log(array3.splice(2,1,"Hello","World")); //這裏才顯示出絞接的含義! // 顯示 [13] console.log(array3); // 顯示 [11, 12, "Hello", "World", 14, 15] -5 -4 -3 -2 -1 | | | | | var array4=[16,17,18,19,20]; | | | | | 0 1 2 3 4 console.log(array4.splice(-2,1,"me")); // 顯示 [19] console.log(array4); // 顯示 [16, 17, 18, "me", 20]
若是Argument(1)是NaN,則將其視爲0。索引
var array5=[21,22,23,24,25]; console.log(array5.splice(NaN,4,"NaN 被看做是 0")); // 顯示 [21,22,23,24] console.log(array5); // 顯示 ["NaN 被看做是 0",25]
若是Argument(2)小於0或等於NaN,則將其視爲0。ip
var array6=[26,27,28,29,30]; console.log(array6.splice(2,-5,"Hello")); // 顯示 [] console.log(array6); // 顯示 [26,27,"Hello",28,29,30] console.log(array6.splice(3,NaN,"World")); // 顯示 [] console.log(array6); // 顯示 [26,27,"Hello","World",28,29,30]
若是Argument(1)或Argument(2)大於Array的長度,則任一參數都將使用Array的長度。get
var array7=[31,32,33,34,35]; console.log(array7.splice(23,3,"Add Me")); // 顯示 [] console.log(array7); // 顯示 [31,32,33,34,35,"Add Me"] console.log(array7.splice(2,34,"Add Me Too")); // 顯示 [33,34,35,"Add Me"] console.log(array7); // 顯示 [31,32,"Add Me Too"]
參數1:必需。一個整數,指定開始選擇的位置(第一個元素的索引爲0)。使用負數從數組的末尾進行選擇。it
參數2:可選。一個整數,指定結束選擇的位置。若是省略,將選擇從數組的起始位置到結尾的全部元素。使用負數從數組的末尾進行選擇。console
var array=[1,2,3,4,5] console.log(array.slice(2)); // 顯示 [3, 4, 5], 返回選定元素. console.log(array.slice(-2)); // 顯示 [4, 5], 返回選定元素. console.log(array); // 顯示 [1, 2, 3, 4, 5], 原數組保持不變. var array2=[6,7,8,9,0]; console.log(array2.slice(2,4)); // 顯示 [8, 9] console.log(array2.slice(-2,4)); // 顯示 [9] console.log(array2.slice(-3,-1)); // 顯示 [8, 9] console.log(array2); // 顯示 [6, 7, 8, 9, 0]
若是任一參數是NaN,則將其視爲0。form
var array3=[11,12,13,14,15]; console.log(array3.slice(NaN,NaN)); // 顯示 [] console.log(array3.slice(NaN,4)); // 顯示 [11,12,13,14] console.log(array3); // 顯示 [11,12,13,14,15]
若是任一參數大於數組的長度,則任一參數都將使用數組的長度
var array4=[16,17,18,19,20]; console.log(array4.slice(23,24)); // 顯示 [] console.log(array4.slice(23,2)); // 顯示 [] console.log(array4.slice(2,23)); // 顯示 [18,19,20] console.log(array4); // 顯示 [16,17,18,19,20]
但願有所幫助.