2 years ago

#48910

test-img

LiBee

New to JavaScript - Let variable

I am learning JavaScript at the moment and please can someone explain to me why the following function would give the value of 9 and 10, as the let a = 10 is outside of the function block and I thought with let variables as they are block-scoped there are not accessible outside the {block}

let a = 10;
function f() {
  let b = 9;
  console.log(b);
  console.log(a);
}
f();

javascript

function

let

0 Answers

Your Answer

Accepted video resources