1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

JavaScriptの変数(const,let,var)。再宣言、再代入の可否について。

Last updated at Posted at 2023-04-28

・変数とは
 複数回使う文字列や数値などのデータに名前をつけることで、
 繰り返し利用できるようにする機能。
 変更する際にも変数だけ変えればよいので、ミスが起こりづらい。

・JavaScriptの変数
 const,let,varの3つある。

・再宣言、再代入
 再宣言 - 1度宣言した変数を、新たに宣言しなおすこと。
  例 const Title = "The Matrix";
    const Title = "The Matrix Reloaded";

 再代入 - 1度宣言した変数に、新たな値を代入すること。
  例 const Title = "The Matrix";
    Title = "The Matrix Reloaded";

・変数ごとの再宣言、再代入の可否
 const 再宣言:x 再代入:x
 let 再宣言:x 再代入:○
 var 再宣言:○ 再代入:○

参考にしたサイト
https://jsprimer.net/basic/variables/ (JavaScript Primer 変数と宣言)
 

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?