Last active
March 30, 2022 17:06
-
-
Save lcy101u/69db1a81103d9515aad437ea6ef4e523 to your computer and use it in GitHub Desktop.
Revisions
-
lcy101u revised this gist
Mar 30, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ const array = ['A', 'B', 'C', 'D', 'E'] console.log(array.slice()) // ['A', 'B', 'C', 'D', 'E'] ,沒有參數,全部拷貝 console.log(array.slice(5)) // [] 如果begin 超過陣列長度會回傳空字串 console.log(array.slice(-1)) // ['E'],begin 是 -1 ,表示從最後一個元素拷貝 console.log(array.slice(-2)) // ['D', 'E'],begin 是 -2,表示從最後兩個開始拷貝 console.log(array.slice(0, 2)) // ['A', 'B'] begin 是 0 到 2 (不包含2) -
lcy101u revised this gist
Mar 30, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,5 +3,5 @@ const array = ['A', 'B', 'C', 'D', 'E'] console.log(array.slice()) // ['A', 'B', 'C', 'D', 'E'] ,沒有參數,全部拷貝 console.log(array.slice(-1)) // ['E'],begin 是 -1 ,表示從最後一個元素拷貝 console.log(array.slice(-2)) // ['D', 'E'],begin 是 -2,表示從最後兩個開始拷貝 console.log(array.slice(0, 2)) // ['A', 'B'] begin 是 0 到 2 (不包含2) console.log(array.slice(0, -1)) // ['A', 'B', 'C', 'D'] begin 0 到 -1 (表示最後一個元素但不包含) -
lcy101u created this gist
Mar 30, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ const array = ['A', 'B', 'C', 'D', 'E'] console.log(array.slice()) // ['A', 'B', 'C', 'D', 'E'] ,沒有參數,全部拷貝 console.log(array.slice(-1)) // ['E'],begin 是 -1 ,表示從最後一個元素拷貝 console.log(array.slice(-2)) // ['D', 'E'],begin 是 -2,表示從最後兩個開始拷貝 console.log(array.slice(0, 2)) // ['A', 'B'] begin 0 到 end 2 (不包含end) console.log(array.slice(0, -1)) // ['A', 'B', 'C', 'D'] begin 0 到 end -1 (表示最後一個元素但不包含)