Skip to content
JS 스코프기술 정리

JS scope

1 min readTech notesMoved from my Tistory blogRead the Korean original

Translated into Korean, the word scope means ‘range’.

In JS, there are 2 types of scope.

global and local.

Example

js
const text = 'outside';

{
    const text = 'inside';
    {
        console.log(text);
    }

}

In the code above, console.log(text) will print inside.

Example

js
const text1 = 'outside';

{
    const text2 = 'inside';
    {
        console.log(text2);
    }

}
console.log(text2);
  • #JavaScript scope
  • #global scope
  • #local scope

More in Tech notes