Help us understand the problem. What is going on with this article?

【Javascript】JS 変数 定数 違い  一言でまとめました

【ゴール】

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

tanaka-yu3
さくっと30秒で読める記事をたくさん 初学者向け
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした