Send by LINE
B! Bookmarks in Hate-bu
Bookmarks in Pocket
RSS feeds

JavaScript var, let, const: How to use variable declaration

Other language site
No available translations found
Google Translate
JavaScript logo

I decided to use JavaScript after a long time, and as I looked up, variations of variable declarations had increased.There seems to be a usage of let, const.

It was two years ago because it was formulated in ES 2015. Oh crap, it is considerably late. I examined it late.


It is conventional usage. Even if a new method is added, it can be used. However, when we prioritize using let, const explained later, we no longer use it.

I am no longer using it.


It is used with variables valid within the declared scope. It can be used as an alternative to the var you have used so far.

Since it also includes the meaning of limiting the scope, we recommend that you use this rather.

When declared in if, for, it becomes a valid variable only in the syntax. It is now possible to use variables with a narrow scope that has never been before.


It is used as a constant. Once you set the value you can not change it. It is used in situations such as storing DOM objects in variables.

Leave a Reply