A let or const declared inside { } exists only in that block. Function parameters and let/const inside a function stay inside that function. Outer names are readable from inner scopes unless shadowed.

Results appear here.

Run a demo to see which names are visible where.

Important JavaScript

const appName = "Scope Lab"; // global for this script

function describe() {
  const label = "inner"; // function scope
  return appName + " / " + label;
}

if (true) {
  const blockOnly = "block"; // block scope
  console.log(blockOnly);
}
// console.log(blockOnly); // ReferenceError

const score = 10;
if (true) {
  const score = 99; // shadows outer score inside this block
  console.log(score); // 99
}
console.log(score); // 10