> For the complete documentation index, see [llms.txt](https://themas.gitbook.io/javascript-function/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://themas.gitbook.io/javascript-function/function-javascript/scope.md).

# Scope

Scope merupakan area akses sebuah data

{% hint style="info" %}

* Ada dua jenis scope, global scope dan local scope.
* Setiap kita membuat function, maka kita akan membuat local scope untuk function tersebut
* Data di global scope bisa diakses dari local scope, namun data di local scope hanya bisa di akses di local scope tersebut atau di scope local dibawahnya (dalam kasus function dalam function)
  {% endhint %}

**Kode : Global Scope**

![](https://lh5.googleusercontent.com/RR3D0q1zWZZopZqrmYWT5zLJOYolmZEuIUJHUiEYCKaOKgKG3imw8p2jb5SoBUSkZzLGeXHc3-NAFaW43xuZFWymIaPAJV3IYakGwCkJMDQgf0vhF0NW2jGYQV7gWlHJTr_vxLIoTF7qdGRChzJDZw)

**Kode : Local Scope**

![](https://lh4.googleusercontent.com/lte6OQYYadyPPCU3uxcVVCBf-2gzyzA-COV4qxLqv3URGVNol0t3wsRDawAJgSmkw2BgwUuFq3A4ix3Tah-HeCU0-KxpFHtwZZfxzKMqI3QqVW4T5N2FxurTMpEDPBZxjc_hl4MUOwtl0dzgg5KyxQ)
