配列を使って一気に変数を宣言する際に、,やスプレッド構文を使って
- 特定の値の取得
- いらない値の選別
ができる
const a = [1,2,3,4,5]
const [ ,b,...rest] = a
console.log(b,rest) // 2 [ 3, 4, 5 ]
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 1 year has passed since last update.
配列を使って一気に変数を宣言する際に、,やスプレッド構文を使って
ができる
const a = [1,2,3,4,5]
const [ ,b,...rest] = a
console.log(b,rest) // 2 [ 3, 4, 5 ]
Register as a new user and use Qiita more conveniently
Go to list of users who liked