showing results for - "difference between let 2c var and const in java script"
Alessia
31 Nov 2020
1var: 
2	- hoisted (always declared at top of scope, global if none)
3    - function scope
4let:
5    - block scope
6    - not redeclarable
7const: 
8    - block scope
9    - not reassignable
10    - not redeclarable
11    
12Note: Although it may seem like these hold only semantic meaning, using the
13appropriate keywords helps the JS engines' compiler to decide on what to optimize.
Damaris
15 Apr 2016
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.
Samuel
18 Jan 2020
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.
Jihane
18 Jun 2018
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
Maceo
20 Oct 2019
1// var is a function scope ***
2if(true){
3    var varVariable = 'This is var';
4    var varVariable = 'This is var again';
5}
6
7console.log(varVariable); // This is var again
8
9// let is a block scope ***
10if(true){
11    let letVariable = 'This is let';
12    let letVariable = 'This is let again';
13
14    // let variable can't re-define but we can re-assign value
15
16
17    console.log(letVariable); // let letVariable = 'This is let again';^SyntaxError: Identifier 'letVariable' has already been declared
18}
19
20console.log(letVariable); //ReferenceError: letVariable is not defined
21
22
23
24// const variable can't re-define and re-assign value
25// const is a block scope ***
26if(true){
27    const constVarible = {
28        name: 'JavaScript',
29        age: '25 years',
30    };
31    constVarible.name = 'JS';
32
33    console.log(constVarible) // {name: 'JS',age: '25 years'} <= we can update const variable declared object 
34}
queries leading to this page
diference between let and constjavascript difference const et letvar and const differencedifference between let 26 constlet vs const in jsdifference in let const and var jsjs const vs let vs varjavascript var 2c let and constdiff between let and const in javascriptconst vs let in jslet v var vs constdifferance between var let constjs difference between var let and constjs difference between let and var and constjs let var const diffconst vs val vs letdifference between var and const in jswhy is var let and const called in javascriptdiff let vs var vs constlet and const js differencedifference between const and var in javascriptjavascript var vs const vs letfdifference between let and const in jswaht is difference bw let and constvar vs const letdifference between const var letlet vs var vs const node jsdifference between var and let and const with exampledifference between const 2clet and vardefference between let const and var in jsdifference between const var and let in jslet and const difference in javascriptvar vs let vs const typescriptwhat is difference between let var and const in javascriptdifference between var const and letis there a difference between let and const variable in js 3f var vs let vs constwhat is the difference between let and var and const in javascriptlet vs const vs var in javascriptdiffernce between var let constdifferent between let const and varjavascript var let const differencewhat are the differences between var 2c let and const 3fdifference between const and letlet and var and const in javascript difference between var let and const in javascriptlet 26 const defferncedifference between var and let and const in javascriptlet var const differencediffrence between var let constwhat are the differences between variables created using let 2c var 2c and constvar let and const diffrence in jsdifference in let const and varlet vs const vs var in jsdiffrence between let const vardifference between const var and letconst vs letjavascropt let vs var vs constlet var and constconst and let differencelet var const differnce javascriptjavascript let or constdifference between const and let in jsdifference between var vs let vs constwhat is diff between const let and var in jsdifference between let and var and constlet var const in javascript didifference between new and var and constwhat are the differences between let 2c const 2c and varlet vas const vs vardifferenec between const and var and let javascriptjavascript difference let constdifference between var 2c let constlet 2c const and var difference between variabledifferences between let const and varwhats difference between let const and vardiff between let const and varthe difference between var and const 26 letvar vs let vs const javascriptdifference of var let and constdifference between var and let and constdifferences between var let and constdifference between const let vardifference between const and let javascriptdifference between var let and const in typescriptdifference between let constant and var in javascriptlet and const diff jsjavascript let vs var vs constdifference between const let and var in javascriptdifferent between var let constdifference of let and const in javascriptvar vs let vs const examplewhat 27s the difference between var let and constdiffefrence between var 2c let and constwhat is the difference between const and let in javascriptwhat is the difference between var let and const in javascriptdifference between let var constexplain the difference between var 2c let 2c 26 constvar 2c let 2c const variable types differencewhat is the difference between const 2c let and vardifference between let 2cvar and constwhat is the diffrence between const 2clet and var in javascriptdifferences between var let constjs const vs letconst vs let vs var in javascriptconst vs let globallet vs const 3flet const var different in javascriptwhat is the difference between let and const in javascriptconst javascript vs letlet vs var vs const javascript differencedifferences between declaring variables using var 2c let and constlet const and var in javascriptwrite the difference between var let and const with code exampleswhat is the difference between const and let 3fdiffernece between let and constdifference between var const and letrdifference between var let and constant in javascriptwhat 27s the difference with let and constdifference between var let const in javascriptdifference between var 2c let 2c consttypescript var vs let vs constconst vs let vs var in jsjavascript let const vs vardifferece between var 2cconst 2cletwhat are the differences between variables created using let 2c var 2c and const 3fvar vs condt vs letdifference between const var and let in javascriptwhat is the difference between var 2c let 2c constjs var vs let vs constlet and const vs varwhat is difference between var and const and letwhat is the difference between let and const 3f what distinguishes both from var 3fdiffrence between const and var in js 5cconst let and var differencewhat are the differences between var 2c let and constdifference between let var const javascriptconst let var difference jslet vs var vs const javascriptdifference between let and var and const in javascript w3schoolswhat is let and const in javascriptdifference between var let and constantfdifference between let var const in jsdifference between var 2clet 2cconst in javascriptdifference let const varwhich is better const vs letwhat is the difference between const var and let in javascriptwhat is the difference between const and let in nodejavascript difference between var and constdiff between var let constdifference between const 2c let and vardifference between let const and var in javascriptwhats the difference between var and const in javascriptscope with var let constthe difference var let and constlet vs const in javascriptdifference between let and const jswhat is the difference between const let and varwhen to use const vs letwhat is diff between w let const and vardifference const var letdifference let var const javascriptdiff between let and const and vardifferenfce between let 26 const javascriptwhat is the difference between let and const in typescriptdifference between var 2c let 2c and constts let vs var vs constdifference between const and let and vardifference between var 2c let and const in javascriptdifferene between let const nodedifference between var let and const with examplediffrence between var 2c let constdifference betwwen const and let 3fdiffrence between let and constvar and let and const differencewhat is the difference let 2c var constjavascript diff between const and vardifference between var 2c let 26 constlet and var and const differencedifference between let var const in jsvar const let differencelet vs var vs constconst vs var vs let in javascriptdifference between var 2c let and const in javascript and best use casesdifference among var 2clet 2cconstlet vs const javascriptwhat are the differences between var 2c let 2c and constdifference between let and const var in javascriptdiffrence in let var constwhat is the difference between variables declared with let 2c const 2c and var 3fdiff between let var and constdifference between variable var and let and const in javascript with exampledifference between const 2c var and let in jsjavascript difference between let var constjavascript var vs let vs constvar vs let vs const 2cdifference between let 2cvar and const in type scriptconst and var vs letvar vs let vs const javascript memorydifferences between var let and const javascriptvar vs const vs let javascriptwhat are the differences between let and constdifference between var let constnodejs const vs var vs letjavascript const vs letvar vs let const javascriptdifference between let and var and const in javascript what is the difference between const and let in jsdifference between let const and vardifference between const and var and letdifference let var and constwhat is the difference between var let constlet vs const vs var in nodejsdiff between let and var and constwhats the difference between let and const 3fwhat is the differences between js var 2c let and constjavascript const vs let vs var unterschiedlet vs constwhat is the difference in let var and const in jsdifference between const 2c var and let in nodejsjavascript difference between const let and varjavascript const vs let vs vardifference of let 2cvar 2cconst 2clet vs const referencelet vs const vs var javascriptjs let vs var vs constdiffence between const let var in jsdifference between let an constdifferent let en constdifference between var and const in javascriptdifference between variable and constant and let in javascriptjavascript difference between var and let and consthwhat 27s the difference between const 2c let and vardifference between const 2c var 2c and letdifference between const and let and var in javascriptstatic vs const vs let vs varwhat are the differences between variables created using let 2c var 2c and const 3f 2alet const vs vars in javascriptwhat is the difference between declaring variables using var 2c let and const what isthe difference bet ween let and var and const in javascriptdifference in var let and constconst vs var vs let javascriptjavascript var vs const and letnode let vs constdifferencr bet var let const in jsvar vs const y letdiff var let constlet vs const vs var vs freezewhat is the difference between let and const in jswhat difference in let var and const in javascript with exampledifference between let var and const in jswhat are the differences between variables created using let 2c var or const 3fjavascript when to use let vs constdifference between var and letjs let vs constthe difference between const and letvar vs let vs const in javascriptconst vs let jsdifference between var 2c let 2c constdifference between let and constant in javascriptnode js let vs var vs constwhat 27s the difference between let and constdifference between var 2clet and constdifference between const let and varreact var vs let vs constdifference const var and let javasciptjavascript let var const differencejavascript difference between const and varjavascript differenct let var constlet var vs constwhat the differences among var 2c const and let 3fjavascript difference between const and letwhat is the difference with const var letdifference between let and var and const in javascript with examplelet vas const vs var exampledifference between const and let in javascriptlet const differencejavascript const vs var vs letlet vs var vs const speeddiffernce between var let and constjs difference const and letdifference between let var and constlet vs var vs const jsjs let vs const vs varlet const var differencewhat is var let and const in javascriptwhat the difference between let const and varwhat is the difference between const var and letwhat is the difference between let var and constdiffernce between var 2clet 2cconstdifference between const 2clet and varjavascript let vs const vs vardifference between let and constconst let and var javascriptdifferenc between var let and constconst in js meaning vs var letdifference let and constdifference const let varvar vs cont vs letwhat is the difference between let 2cvar and const in javascriptuse of let and const in javascriptdifference between let and const and var differnce between var and let and const jswhen to use let vs constvar vs let vs const in jsconst vs let javascriptwhat is difference between const let and var typeswhat is difference between var const letvar let const differencediff b 2fw let var const in jsconst vs let vs var javascriptwhats the difference between var let constjavascript var vs let and constdifference between var and const javascriptwhat is difference between let and var and const in javascriptlet vs var vs const in jslet vs const in java scriptwhat is the difference between let 2c var and const in javascript 3fdifferences between javascript var 2c let and constconst vs var vs letvar vs const and letdifference between let and const in java scriptvar or let or constdifference with const let in functionsconst vs let vs varconst vs let vs var in jis there an actual difference between var 2c const 2c and letdifference between const and let in nodejsdifference between var const let in javascriptdifference between let 2c const and var javascriptconst vs var vs letdifference var let const javascriptwhat is the difference between let const and varwhat is the difference between let 2c var 2c and const 3fis let a const javascriptdifference between let and const in es6difference between let and const javascriptdifference between var let and const in javascript with exampledifference const let javascriptdifferent between let and const and varwhat is the difference between var let and const latest newsdifference between var const and let in javascriptdifference between var and let constdifference of var 2c const and letlet and const variables in javascriptvar 2c let and constdifferences between const let and varlet var and const in javascriptwhat are the differences between let 2c const and var 3fwhat is the difference between var let and const 3fdifference between var let const in jsjavascritp let vs constdifference between let and const in javascript with exampledifference between var 2c let and const with examplelet vs var constdifference in const and letwhat is difference between var let and const in javascriptconst let var differencewhat is difference between let var and constdifference between var let and const in jswhat diferrence in let 2c var and const in javascriptdifference between const var and let javascriptjs difference between const and letvar let and const in javascriptdifference const and let in jsvar vs let and constlet const vs vardifferences between let var and constdefferent between const let vardifference let var constdifference between var let and const in javascript with examplescan you use let and const with the same variable in jsdifferences between declaring variables using var 2c let and const javascript for let vs constwhat is the difference between 22let 22 and 22const 22 in javascriptconst vs let vs anyconst vs let vs var vs functionvar 2c let 2c and const e2 80 93 what 27s the difference 3fdifference betwen let var and constdifference between let 2cconst 2cvardiff b 2fw var let const jsjavascript var let and constwht is difference between let 2c const and vardifference between const 2c let and var in jslet var and const differencedifference between let and const object javascriptdifference between var const 26 let in javascriptvar vs let vs const javascript with examplesconst vs let in javascriptlet vs var vs constantdifference between const 2clet 2cvardiff between var let and constdiffernce between var 2clet and constin javascript 2c what is the difference between 60var 60 2c 60let 60 2c and 60const 60 3fvar let and const differencevar vs let vs const jslet vs constant vs var in javascriptlet vs const jswhats the difference between const and var in jsvar 2c let 2c and const what is the differencedifference var let constwhat is the different between var and let and const in jsthe diffrence between var let constjavascript const let differencewhat is difference between let and const in javascriptdifference between const let var newdiff between let and const constdifference between let 2c var 2c consthow let and const is differnce from var in jsdifferenec between var let and constdifference between var 2c const and letwhat is difference between const and var and let 23 3fconst differencewhat is difference between let const varconst var let differencediff between let and constdifference of let and constvar vs const vs letvar let const difference jsdifference between var let and const javascriptdifferenv between let and constjavascript let vs constdifference between let 2c const and var in javascriptdifference const and letwhat is the different between const and letdifference among var 2c let and const in javascriptwhat is the difference between var 2c let 2c and const 3fwhat is the difference between var let and constdifference b 2fw var let and constdiff bw var let and const in jswhat is the difference between const and var in javascriptcompare between let and var and const in javascriptdifferenece between let and constdifference between let 2c var and constdiference between const 2c var 2c letdifference between const let and var keyword in javascriptdifference between var let and const in typescript javatutodifference between var 2c let 2c and const keywords in javascriptlet var and const difference in jslet and const var diffdifference between let const varwhat is difference between var and let and const in javascriptdifference between const and var javascriptwhy use let vs constdifference between let var const in javascriptdiff between const and var in javascriptdifferences between var 2c let 2c and constdifference between cvar let constwhat is the difference between var and const in javascriptdifferences of let 2cconst and vardifference in let and constjavascript difference between var let and constjavascript let and constwhat is the difference betwen var and let and const 3flet and const differencedifference between var let and constdiff between const let and varwhat is the difference between var 2c let 2c and const differences between var 2c let and const in javascriptthe difference between const and var in javascriptvar let const javascript differencedifference of const let and varwhat is the difference between const and letdifference between let and const in javascriptdifference between let 2c const and var jsjavascript let const differencevar vs const vs let jswhat is difference between const vs let vs var what are the differences between var 2c let and constwhat is the difference between let var and const typescriptdifference between var 2c let and constdifference between let var and const in javascriptdifference between let const and var javascriptlet vd constdifference between const car and let in jswhat is different between let and constwhat is difference between var let constlet vs const vs varwhat are the differences between var let and constlet and const javascript difference performancewhy const vs letdifference bw let and const variablesvar vs let vs constdifference between let and const in jsdifference between const and varlet vs var vs const vs valdifference between var let constjs const vs var vs letjavascript difference between let and constwhat is the difference among var 2c let 2c constlet vs const vs var jswhat is defferent between var let constlet var const difference javascriptdifferences between var 2c let and constdifference between var 2c const 2c letdifference between let 2c var and const in javascripttypescript const vs let vs vardifference between let 2c var and const in java scriptdiff betwwen const var and letvar let vs constjavascript constant vs letwhat is the difference between let var and const in javascriptwhat is difference between var and let and const in javascript with examplejavascript use var or let or constlet vs const what is betterdiffernece between var let constwhen to use var vs letlet vs var vs const in javascriptjs variables differences var let constlet vs var vs const javascript tdzwhen to use var let and const in javascriptjs var vs const vs letwhat are the differences between let 2c const and vardifference between let 2c var and const in java script