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】JS 変数 定数 違い  一言でまとめました

Posted at

##【ゴール】
javascriptの変数、定数の違い

##【メリット】
* javascript理解度向上

##【コード】
###変数(var , let)
中身を何回も更新できる

####var
*再宣言可能
*再宣言の際に(var)は不要

hoge.js
var name = "太郎";

console.log(name); // 太郎が出力


name = "次郎"

console.log(name); //次郎が出力

var name = "三郎"; //再宣言可能

let

*同変数名は一度しか宣言できない

hoge.js
let name = "太郎";

console.log(name);  //太郎が出力

let name ="次郎"; //エラー出る...

###定数
中身は一回だけ決めれる

const

hoge.js
 const name = "太郎";
 
 console.log(name); //太郎と出力

##【合わせて読みたい】

■JavaScriptで書く「let,var,const」の違い・使い分け
https://techacademy.jp/magazine/14872

■ 【JavaScript】 js 繰り返し文 for / while
https://qiita.com/tanaka-yu3/items/942d9d4838ebe14be1c2

■ 【jQuery】初心者でもよく理解できたやつ
https://qiita.com/tanaka-yu3/items/a03734b248c3f2ee8461

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?