function scope () { if (true) { const a = 123 console.log(a) // 값: 123 } } scope() function scope () { if (true) { const a = 123 } console.log(a) // ReferenceError } scope() function scope () { if (true) { console.log(a) // 값: undefined const a = 123 } } scope()
function scope () { console.log(a) // 값: undefined if (true) { var a = 123 } } scope() function scope () { if (true) { console.log(a) // 값: undefined var a = 123 } } scope() function scope () { if (true) { var a = 123 } console.log(a) // 값: 123 } scope()