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”;

The above code would give the result as Ajith beca…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Sujith V S

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";

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";

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


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Sujith V S


Print Share Comment Cite Upload Translate Updates
APA

Sujith V S | Sciencx (2022-09-06T14:06:01+00:00) let & const | JavaScript ES6.. Retrieved from https://www.scien.cx/2022/09/06/let-const-javascript-es6/

MLA
" » let & const | JavaScript ES6.." Sujith V S | Sciencx - Tuesday September 6, 2022, https://www.scien.cx/2022/09/06/let-const-javascript-es6/
HARVARD
Sujith V S | Sciencx Tuesday September 6, 2022 » let & const | JavaScript ES6.., viewed ,<https://www.scien.cx/2022/09/06/let-const-javascript-es6/>
VANCOUVER
Sujith V S | Sciencx - » let & const | JavaScript ES6.. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/09/06/let-const-javascript-es6/
CHICAGO
" » let & const | JavaScript ES6.." Sujith V S | Sciencx - Accessed . https://www.scien.cx/2022/09/06/let-const-javascript-es6/
IEEE
" » let & const | JavaScript ES6.." Sujith V S | Sciencx [Online]. Available: https://www.scien.cx/2022/09/06/let-const-javascript-es6/. [Accessed: ]
rf:citation
» let & const | JavaScript ES6. | Sujith V S | Sciencx | https://www.scien.cx/2022/09/06/let-const-javascript-es6/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.