0
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 3 years have passed since last update.

【今日Javascriptを始めた人向け2】変数の更新

Last updated at Posted at 2020-04-25

【今日Javascriptを始めた人向け1】の続きです。

変数に値を再代入すれば変数の値の更新が出来ます。

【例】

sample.js
let hoge = 3;
console.log(hoge);
hoge = 5;
console.log(hoge);

こちらの実行結果は

実行結果
3
5

となります。3行目の

hoge = 5;

hoge = 5;の記述部分で値が5に更新されています。

代入は何回でも行えますが変数の値は直前に代入した値になります。なので変数を使用する際は直前に代入した値を把握しておきましょう。

0
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
0
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?