01 / 05
配列にも `readonly` が付けられる
オブジェクトのプロパティに readonly を付けて「あとから変えない」と宣言したのを覚えているかな。同じことが配列そのものにもできるよ。
書き方は、配列の型の前に readonly を置くだけ。readonly string[] は「読むだけの、文字列の配列」という意味になる。
const iro: readonly string[] = [ "あか", "あお",];console.log(iro.length);実行結果
2