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?

[JavaScript] 変数

Last updated at Posted at 2024-10-28

環境

MacBook Pro (2.3 GHz 8コアIntel Core i9)
macOS 14.0(23A344)
Homebrew 4.3.8
gh 2.52.0

まとめ

再代入(上書き) 再宣言
var Yes Yes
let Yes No
const No No

目次

var

略: Variable(変数)の略
再代入(上書き): Yes
再宣言: Yes

index.js
var val1 = "var変数";
console.log(val1);

// var変数は上書きが可能
val1 = "var変数は上書き";
console.log(val1);

// var変数は再宣言可能
var val1 = "var変数を再宣言";
console.log(val1);

let

略: 特に略ではない
再代入(上書き): Yes
再宣言: No

index.js
let val2 = "let変数";
console.log(val2);

// let変数は上書きが可能
val2 = "let変数を上書き";
console.log(val2);

// let変数は再宣言不可能
let val2 = "let変数を再宣言";

const

略: Constant(定数)の略
再代入(上書き): No
再宣言: No

index.js
const val3 = "const変数";
console.log(val3);

// const変数は上書きが不可能
val3 = "const変数を上書き";
console.log(val3);

// const変数は再宣言不可能
const val3 = "const変数を再宣言";
console.log(val3);

参考リンク

0
0
2

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?