Home / Javascript Tips Generated By ChatGPT / Understanding Scope in Javascript Variables have function scope or block scope (let and const). Source Code function testScope() { let localVar = 'I am local'; console.log(localVar); // Accessible here } console.log(localVar); // Error: localVar is not defined