DEV Community

Sujith V S
Sujith V S

Posted on • Edited on

2 1 1 1 1

let & const | JavaScript ES6.

let and const are used to create variable in js.

let is same as var in old js. let allows us to create variables where its values can be changed.
eg:-

let myName = "Sujith";
myName = "Ajith";
Enter fullscreen mode Exit fullscreen mode

The above code would give the result as Ajith because we have reassigned a new value to the variable myName.

const is used to create a variable where its value cannot be changed or reassigned after initial assignment.

const myName = "Sujith";
myName = "Ajith";
Enter fullscreen mode Exit fullscreen mode

The above code would give us the following error.
TypeError: Assignment to constant variable.

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay