INDEX
はじめに
![](https://techlog.site/wp-content/uploads/2024/02/nwe_icon.jpeg)
初めてのTypeScriptを読みました。
その学習を記録します。
![40036_learning_typescript_cvr](https://techlog.site/wp-content/uploads/2024/04/picture_large978-4-8144-0036-2.jpeg)
![40036_learning_typescript_cvr](https://techlog.site/wp-content/uploads/2024/04/picture_large978-4-8144-0036-2.jpeg)
結論
const foodList = (...foods:string[]) => foods
使い方
全ての引数を配列にする
const foodList = (...foods:string[]) => foods
console.log(foodList('たまご', '納豆', '豆腐', 'ゼリー', 'めかぶ'))
実行結果を確認する
["たまご", "納豆", "豆腐", "ゼリー", "めかぶ"]
最初の値は配列に含めない
const foodList = (egg:string, ...foods:string[]) => foods
console.log(foodList('たまご', '納豆', '豆腐', 'ゼリー', 'めかぶ'))
実行結果を確認する
["納豆", "豆腐", "ゼリー", "めかぶ"]