what is the difference between let and const in javascript

Solutions on MaxInterview for what is the difference between let and const in javascript by the best coders in the world

showing results for - "what is the difference between let and const in javascript"
Juan Sebastián
18 Jul 2018
1//let is used to declare the variable or initialize a variable..
2//let variable can be updated in future.
3//Its block scope and we cannot redeclare it.
4
5let a; // Initializing the variable.
6let b = 4; // Initializing and declaring variable.
7let b = 5; //Error:- cannot redeclare a value but we can update the value.
8
9//var is just like let but var is used to declare a variable value at top of
10//the program, its hoisted.
11
12var a; // Initializing the variable.
13var b = 4; // Initializing and declaring variable.
14var b = 5; //b will be redeclared and we can update its value.
15
16//const variable should be declared and intialized at same time.
17//const variable cannot be updated in future.
18//we cannot even redeclare the variable in future.
19
20const a = 10; //Initilizing and declaring a variable at a time.
21const b; //Error:- const should be declared and intialized.
22const a = 11 // Error:- cannot redeclare the variable again.
Keira
28 Sep 2019
1The difference is that with const you can only only assign a value to a variable
2once, but with let it allows you to reassign after it has been assigned.
Leon
29 Oct 2019
1//functional scope 
2 var a; // declaration
3 a=10; // initialization; 
4//global scope
5// re-initialization possible
6 let a;//only blocked scope & re-initialization possible
7 a=10;
8let a =20;
9if(true){
10  let b =30;
11}
12console.log(b); // b is not defined
13const // const also blocked scope,Re-initialization and re-declaration not possible
14const a; // throws error {when we declaring the value we should assign the value.
15const a =20;
16if(true){
17  const b =30;
18}
19console.log(b); // b is not defined
20console.log(a); // no output here because code execution break at leve b.
21
queries leading to this page
difference between var and let and const with examplejavascript let const differencejavascript for let vs constdifference b 2fw var let and constlet and const difference in javascriptjavascropt let vs var vs constlet and const diff jswhat is the difference between 22let 22 and 22const 22 in javascriptlet const vs vars in javascriptdifference between let 2c const and var javascriptconst var let differencedifference between const and let and varlet and const js differencelet vs const in javascriptdifference with const let in functionsdifferences between var 2c let 2c and constdifference between var 2c let 26 constthe difference between const and var in javascriptdifference between var 2c let and const with exampledefference between let const and var in jsdifference between let 2c const and var jslet vs const javascriptdifferent between let and const and vardifference between const var and let in javascriptwhat is the difference betwen var and let and const 3fdifference between var 2clet and constvar vs let vs const javascriptdifference between let 2c var and constdifference between var 2c let and const in javascriptjs difference const and letlet vs var constthe diffrence between var let constdifference between const and var javascriptdifference const let varjavascript difference between var let and constjavascritp let vs constwhat are the differences between variables created using let 2c var 2c and const 3fjs var vs let vs constdiff b 2fw let var const in jsjavascript when to use let vs constlet var const differnce javascriptwhat are the differences between var 2c let and const 3fwhat is the difference between var 2c let 2c and const let and const vs vardifference let var const javascriptvar vs let vs constwhat is the difference between let and const in javascriptjavascript let const vs vardifference between let and consthow to let a const in java script where there is vardifference between let and const in java scriptdifference between let and var and constwhat is the difference between let const and varjs const vs letwrite the difference between var let and const with code examplesjavascript difference const et letwaht is difference bw let and constwhats the difference between var and const in javascriptdifference between var const let in javascriptdifferences between const let and vardifference between var const and let in javascriptwhat is the difference between const var and letwhat is the difference between const and var in javascriptvar vs let const javascriptlet vs var vs const javascript differencevar vs let vs const 2cwhat is the difference between let var and constdifferences between let const and vardifference between let and const jswhat is diff between w let const and varlet const var different in javascriptjs const vs let vs vardifference between var 2c let and const in javascript and best use caseswhat is the different between const and letdiffrence between let and constdifference in var let and constdifference between var let and const in javascript with exampledifference of let 2cvar 2cconst 2cdifference between const 2clet 2cvarjs let vs constdifference between const and vardifference between const 2c var and let in jsvar 2c let 2c and const e2 80 93 what 27s the difference 3fdifference var let const javascriptjavascript const vs letwhat is the difference between const var and let in javascriptlet and const differencejs const vs var vs letdifference between let 2c var 2c constdifference between const var and let in jsconst vs let jsconst vs let in javascriptwhat is the difference between declaring variables using var 2c let and const what are the differences between variables created using let 2c var 2c and const 3f 2awhat are the differences between var 2c let and constjavascript var vs const and letdifference between let and var and const in javascript w3schoolsjs let var const diffjavascript let vs constwhat is difference between let and const in javascriptvar vs let vs const javascript memorydifference between let var and const in jsjs let vs const vs varwhat are the differences between let 2c const and vardifference between let 2c var and const in java scriptdiff between const and var in javascriptwhat is the difference with const var letdifference between var let const in jslet and const variables in javascriptjavascript difference between var and let and constwhat isthe difference bet ween let and var and const in javascriptdifference let const varjs let vs var vs constdifference between var let constdifference between const let and var in javascriptdifference between const and let in jsdifference between var 2c let and constwhat is different between let and constwhat is the difference let 2c var constdifference between let and const object javascriptdifference between let and var and const in javascript difference between var let and constant in javascriptdiffernece between let and constconst let and var differencedifference between var 2c let constlet const and var in javascriptwhat is diff between const let and var in jsdifference of let and constdifference between const var and let javascriptwhat is the difference between var 2c let 2c and const 3fvar vs let vs const jswhat is the difference between const and let in nodewhat is the difference between let and var and const in javascriptcompare between let and var and const in javascriptdifference between let var const in javascriptwhat is the difference between var let and constlet vs const vs var javascriptjavascript var 2c let and constwhats difference between let const and varwhat is the difference between var and const in javascriptdifference in const and letwhat diferrence in let 2c var and const in javascriptdifference between const var and letvar vs const vs letlet and var and const differencejavascript const let differencejavascript difference let constjavascript var vs let vs constlet vs const jsdifferenc between var let and constscope with var let constconst vs let vs var javascriptdifference between const and let javascriptfdifference between let and const in jsdifference between let and const in es6diffrence between var 2c let constlet vs var vs constwhat is the difference between let and const in typescriptdifference between const 2c let and varis there an actual difference between var 2c const 2c and letjavascript const vs var vs letdifference between let 2c var and const in javascriptdifference between var 2c const and letjavascript differenct let var constdifference between var let const in javascriptdifference between const var letdifferences between let var and constwhat is defferent between var let constdifference between let var const in jsdifference between let and const in jsdifference between const let var newdifference between let var and constdifference between let const varvar vs let vs const in jswhat difference in let var and const in javascript with examplewhat is the difference between let 2cvar and const in javascriptlet vs const vs var in javascriptdifferenece between let and const what are the differences between var 2c let and constwhat is the difference between let var and const in javascriptdifference between var and const in javascriptdifference between const and let in nodejsdifference among var 2c let and const in javascriptjs difference between const and letjavascript use var or let or constdifference between const 2clet and varjavascript difference between let and constfdifference between let var const in jsdiffernce between var 2clet 2cconstlet 2c const and var difference between variablejs difference between var let and constdifference between let and var and const in javascript with exampledifference between let and const in javascript with examplewhat is difference between let const vardiff between let and const and vardifference in let const and var jslet vs var vs const javascript tdzlet vs const vs var in jsdiff b 2fw var let const jsdiffence between const let var in jsdifference between let constant and var in javascriptdifferences between var let and constconst vs letwhat is the difference in let var and const in jsdifference between let const and var javascriptdiff between let and const constjavascript var vs let and constdifference between variable var and let and const in javascript with exampledifference between const and var and letlet var and const in javascriptdifferences between var let and const javascriptwhat is difference between var and const and letwhat are the differences between let and constwhy is var let and const called in javascriptdifference between var 2clet 2cconst in javascriptin javascript 2c what is the difference between 60var 60 2c 60let 60 2c and 60const 60 3fvar let and const differencewhat are the differences between var 2c let 2c and constdifference between const and letdifference let var constdifference between const 2c var and let in nodejswhat is the difference between var let constjavascript diff between const and varjavascript var let and constdifferencr bet var let const in jsvar 2c let 2c const variable types differencedifference between let const and vardifference betwwen const and let 3flet vs const vs var in nodejsis there a difference between let and const variable in js 3f var vs let vs const in javascriptdifference between var 2c const 2c letwhats the difference between const and var in jslet vd constconst let var differencewhat is the difference between let var and const typescriptdifference between let an constdifferenfce between let 26 const javascriptwhat is difference between var let constnode const vs let vs vardifference between let var and const in javascriptwhat are the differences between let 2c const 2c and vardifference between const and let in javascriptdifference between const let vardifference in let const and varwhat are the differences between var let and constdifference between var let and const in jslet var const differencevar let const differencedifference between var let and const in typescript javatutohwhat 27s the difference between const 2c let and varwhat are the differences between variables created using let 2c var or const 3fvar let and const diffrence in jsdifference of let and const in javascriptdifference between var and const javascriptwhat is difference between let var and const in javascriptwhat is the difference between const let and varjavascript difference between const and vardifference between var 2c let 2c and constwhat is the difference between const 2c let and vardifference between const and let and var in javascriptwhat is the difference among var 2c let 2c constconst vs let in jsconst let and var javascriptwhat is difference between let and var and const in javascriptwhat is the difference between var let and const 3fconst vs let javascriptdiffernce between var and let and const jsdifference between let and const in javascriptdiff between let and constvar vs const vs let jsjavascript var vs const vs letwhat is the difference between const and let 3fnode js let vs var vs constdifferenec between const and var and let javascriptdifference of const let and vardifference between let 2c const and var in javascriptdiffrence between const and var in js 5cjavascript let vs var vs constlet var and constlet 26 const defferncediffernce between var let and constdifference between const let and vardifference between var let constdifference between new and var and constvar and const differencejavascript constant vs letdiff between let and const in javascripthow let and const is differnce from var in jsjavascript var let const differencewhat 27s the difference between var let and constdifference let var and constlet var and const difference in jsdifference among var 2clet 2cconstconst and let differencewhats the difference between let and const 3fdifference between let and constant in javascriptdifference between var let and const in typescriptdifference between let const and var in javascriptthe difference between var and const 26 letdifference between let 2cconst 2cvardifference const and let in jscan you use let and const with the same variable in jsdifferent between var let constwhat is the differences between js var 2c let and constwhat is the difference between const and letdifferences between var 2c let and constwhat is the difference between let and const 3f what distinguishes both from var 3fdifference between var 2c let 2c constjs difference between let and var and constwhat is the diffrence between const 2clet and var in javascriptdifferenec between var let and constdifference const let javascriptdifference betwen let var and constdifferences between declaring variables using var 2c let and constdifference between var 2c let 2c constdifference var let constconst vs let vs varwhat is the difference between var 2c let 2c constvar let and const in javascriptvar let const difference jslet and const javascript difference performancewhat are the differences between let 2c const and var 3fdifferance between var let constdifferences between javascript var 2c let and constvar let const javascript differencejs variables differences var let constdifference between var let and const with examplewhat is let and const in javascriptdifferene between let const nodedifferences between var let constwhat is difference between let var and constlet vs var vs const javascriptwhat is difference between var and let and const in javascriptdifference between var and const in jsdiff between let var and constdifference between let var const javascriptdifference between var let and const javascriptdifferece between var 2cconst 2cletdifferent let en constdifference between var let and constjs var vs const vs letdifference between variable and constant and let in javascriptconst and var vs letdifference between var let and const in javascript with exampleslet vs const in jsdiff bw var let and const in jsdifference let and constwhat 27s the difference with let and constdiffrence between var let constlet const differencedifference between let and const and var difference const var letdifference between const let and var keyword in javascriptlet vs const in java scriptuse of let and const in javascriptvar and let and const differencejavascript difference between let var constlet const var differencejavascript const vs let vs var unterschiedwhen to use var let and const in javascriptlet vs constant vs var in javascriptwhat the differences among var 2c const and let 3fdiffernce between var 2clet and constdiff between let and var and constwhat 27s the difference between let and constvar vs let vs const javascript with examplesconst vs var vs letwhat is var let and const in javascriptdifferences between var 2c let and const in javascriptlet var const difference javascriptjavascript let and constdifference between var and let and constjavascript difference between var and constvar vs let vs const examplejavascript let var const differencejavascript let or constlet var and const differencedifferent between let const and varconst vs var vs let javascriptdifference between let and const javascriptexplain the difference between var 2c let 2c 26 constdifference between const car and let in jsdifference between var and let and const in javascriptlet and var and const in javascript let vs var vs const jsdifference const var and let javasciptlet vs const vs varwhat is the difference between var let and const in javascriptconst let var difference jsdifference between let and const var in javascriptlet vs var vs const in javascriptdifference between var let and const in javascriptlet const vs varwhat is the difference between let 2c var 2c and const 3fwhat is the difference between let and const in jsthe difference between const and letwhat is the difference between let 2c var and const in javascript 3fconst vs let vs var in jwhat is the difference between const and let in jsdifference between const and var in javascriptwhat is the difference between const and let in javascriptdifference between var 2c const and letdifference between var and let constis let a const javascriptlet var const in javascript diwhat is difference between const let and var typeswhat is difference between var and let and const in javascript with examplewhat is difference between const and var and let 23 3fwhat is difference between var let and const in javascriptjavascript const vs let vs varjavascript difference between const and letdifference between const 2c var 2c and letwhat is the different between var and let and const in jsconst differenceconst vs let vs var in jsconst vs let vs var in javascriptdifference between var 2c let 2c and const keywords in javascriptdiff between var let and constwhat is the difference between let and const in javascript