Answers for "let and const js"

13

let in javascript

The let statement declares a block scope local variable, optionally initializing it to a value.

let x = 1;

if (x === 1) {
  let x = 2;

  console.log(x);
  // expected output: 2
}

console.log(x);
// expected output: 1
Posted by: Guest on April-02-2020
1

var let const javascript

// `let` vs `var` vs `const` in 'javascript'

"let" allows you to declare local variable whose scope 
      is limited to the block statement.

"var" allows you to declare a variable globally or locally 
      to an entire function.

"Const" just like let, are block-scoped.
        It's value can't be reassigned and it can't be redeclared.
Posted by: Guest on November-19-2021

Browse Popular Code Answers by Language