# Lexical Scope and Arrow Functions

In JavaScript, the term "lexical scope" refers to the way that the code in a function can access variables and other declarations that were in place when the function was defined. This means that variables and declarations that are defined in an outer scope (such as the global scope) are accessible to the code inside a function, but the code inside the function cannot access variables and declarations that are defined inside the function from an outer scope.

An "arrow function" is a type of function that is defined using the `=>` syntax. Arrow functions are similar to regular functions, but they have a few differences in terms of how they behave with respect to lexical scope.

One of the main differences between regular functions and arrow functions is that arrow functions do not have their own `this` value. Instead, they inherit the `this` value from the enclosing scope. This can make it easier to work with `this` inside an arrow function, because you don't have to worry about the `this` value being changed by calling the function in different ways.

Here is an example of an arrow function that uses the `this` value from the enclosing scope:


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://demirels-organization.gitbook.io/javascript-tutorial/lexical-scope-and-arrow-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
