生成連續數字陣列


Posted by mijouhsieh on 2023-04-14

const number = Array.from(Array(count).keys())
生成一個長度為 count 的連續數字陣列。
假設 count 是 7,那麼 number 就是 [0, 1, 2, 3, 4, 5, 6]。

Array.from()
Array(count).keys()


#generate-consecutive-numbers







Related Posts

Fetch 與 Promise (四):淺談 Promise

Fetch 與 Promise (四):淺談 Promise

 [ 學習筆記系列 ] 網頁本質 (三) - JavaScript 篇

[ 學習筆記系列 ] 網頁本質 (三) - JavaScript 篇

同步(Sync)& 非同步(Async) 、回呼(Callback)、Promise + then() + catch()、async + await + try + catch

同步(Sync)& 非同步(Async) 、回呼(Callback)、Promise + then() + catch()、async + await + try + catch


Comments