JS scope
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