scope - 식별자 접근 규칙에 따른 유효 범위이다. 안쪽에서 바깥쪽으로는 접근 가능하지만 반대는 불가능하다. 중첩이 가능하다. Global Scope와 Local Scope가 있다.
function jean(){
let brand_name = "PLAC";
console.log(brand_name);
}
jean();
console.log(brand_name);
brand_name은 local scope로 console.log(brand_name)에서는 사용할 수 없다. 바깥쪽에서 안쪽으로는 접근이 불가능하기 때문이다.
let brand_name2 = "GU";
function jean2(){
console.log(brand_name2);
}
jean2();
brand_name2는 global scope로 jean2 함수 내에서 사용할 수 있다.
'프로그래밍 > Java Script' 카테고리의 다른 글
Java Script - Rest parameter (0) | 2022.12.11 |
---|---|
Java Script - Default function parameter (0) | 2022.12.11 |
Java Script - this (0) | 2022.12.11 |
Java Script - 크롬 개발자 도구 Chrome (0) | 2022.12.09 |
Java Script - Window 객체 (0) | 2022.12.08 |