Functions
Scope
Scope is where a variable can be used.
const site = "TechSnow"; // global: usable everywhere
function show() {
const lesson = "Scope"; // function scope: only inside show()
if (true) {
const tip = "Use const"; // block scope: only inside these braces
console.log(site, lesson, tip);
}
// console.log(tip); ← error: tip is not defined here
}
show();