Answers for "let vs const vs var in js"


var vs let vs const

	- hoisted (always declared at top of scope, global if none)
    - function scope
    - block scope
    - not redeclarable
    - block scope
    - not reassignable
    - not redeclarable
Note: Although it may seem like these hold only semantic meaning, using the
appropriate keywords helps the JS engines' compiler to decide on what to optimize.
Posted by: Guest on May-11-2021

difference between var let and const in javascript with example

//functional scope 
 var a; // declaration
 a=10; // initialization; 
//global scope
// re-initialization possible
 let a;//only blocked scope & re-initialization possible
let a =20;
  let b =30;
console.log(b); // b is not defined
const // const also blocked scope,Re-initialization and re-declaration not possible
const a; // throws error {when we declaring the value we should assign the value.
const a =20;
  const b =30;
console.log(b); // b is not defined
console.log(a); // no output here because code execution break at leve b.
Posted by: Guest on February-12-2021

Browse Popular Code Answers by Language