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の変数定義

Posted at

Rubyでは定義したい変数名を記述するだけで変数定義が可能だが、JavaScriptでは変数定義の様式は、var、const、letと3つ存在する。

var

再定義、再代入可能

var 変数名 = ""

変数名 = "再代入する値"

const

再代入、再定義ともに不可
再代入、再定義を行うとエラーが起こる

const 変数名 = ""

let

再代入は可、再定義は不可
再定義を行うとエラーが起こる

let 変数名 = ""

変数名 = "再代入する値"

letとconstの使い分け

再代入する予定のある変数を定義する際はletを使用する
再定義する予定のない変数を定義する際はconstを使用

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?