JavaScript/予約語/let
表示
< JavaScript | 予約語
変数を定義する let
[編集]letキーワードは、変数を定義するキーワードです。定義するときに、値を入れなくても構いません。入れなかった場合は、「undefined」が入れられます。
let price = 1500;
console.log('price = ' + price);
実行結果
price = 1500
let の配列
[編集]letの配列の作り方は、constのときと一緒です。
let array = ['index0', 'index1', 'index2', 'index3'];
console.log(array);
実行結果
(4) ['index0', 'index1', 'index2', 'index3']
0: "index0"
1: "index1"
2: "index2"
3: "index3"
length: 4
︙
letの配列は値の書き換えや代入が可能です。