Loading Depth Study
Preparing your workspace
Scope defines where a variable can be accessed inside a program.
Not every variable should be available everywhere. Local variables belong to a function or block, while broader scopes can make values available to larger parts of a program. Understanding scope helps avoid naming conflicts, accidental changes, and difficult debugging problems. Different languages implement scope differently, but the basic principle is that names have a defined visibility area.
A function may create a temporary calculation variable that should not be accessible by unrelated parts of the application.
const appName = "Study App";
function showUser() {
const userName = "Aman";
console.log(appName);
console.log(userName);
}
showUser();Study App Aman