DEV Community

Cover image for let vs const - Let's discuss.

let vs const - Let's discuss.

Kumar Abhirup on March 22, 2020

We all are familiar with the difference between const, let and var. If not, please read this. Var, let and ...
Collapse
 
sargalias profile image
Spyros Argalias

constant for all. It's useful information to the developer about the future of the value (that it won't change). It follows that seeing let guarantees that the value will change because it is necessary.

The additional information can be helpful.

Collapse
 
kumareth profile image
Kumar Abhirup

Agreed.

Collapse
 
mudlabs profile image
Sam

CONSTANT FOR ALL team member checking in.

Collapse
 
kumareth profile image
Kumar Abhirup

Nice. I got a teammate. âš¡

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

I believe, the best should be CONSTANT FOR ALL, and not only constant for all, but also IMMUTABILITY. That is, avoid mutation, whether instance or memory address.

Collapse
 
kumareth profile image
Kumar Abhirup

I like that.

Collapse
 
sergchr profile image
Serhii

Would you write about arrow functions?

Collapse
 
kumareth profile image
Kumar Abhirup

Yes! What would you like to know from me?

Collapse
 
sergchr profile image
Serhii

How to use them in general

Thread Thread
 
kumareth profile image
Kumar Abhirup

DM me @kumar_abhirup on Twitter about this :)

Collapse
 
apoorvsingal profile image
Apoorv Singal

Well, variables delcared using const keyword are allocated on stack instead of the heap (unless you're using closures), making them way faster than the variables declared with let. So, constant for all.

Collapse
 
iamkalai profile image
Kalaiarasan Pushpanathan

I don't understand the hype of "arrow function" and "const" guy checks in. I understand the need but not the hype.

Collapse
 
saurabhdaware profile image
Saurabh Daware 🌻

const for all. Though I do agree to Dan's point that it can be confusing for beginner when you're dealing with objects.

Collapse
 
kumareth profile image
Kumar Abhirup

🔥