# Scope Functions

The Katxupa library contains several functions whose sole purpose is to execute a block of code within the context of an object. When you call such a function on an object with a lambda expression provided, it forms a temporary scope. In this scope, you can access the object through ***it*** or in some cases ***this***. Such functions are called scope functions.

There are five of them: ***letIt***, ***runIt***, ***withIt***, ***applyIt***, and ***alsoIt***.

Basically, these functions all perform the same action: execute a block of code on an object. What's different is how this object becomes available inside the block and what the result of the whole expression is.

Here's a typical example of how to use a scope function:

```typescript
({name: "Manuel Santos", age: 36, email: "ney.br.santos@gmail.com"})
    .letIt(it => {
        console.log(it);
        it.age++;
        console.log(it);
    });
```

If you write the same without letIt, you'll have to introduce a new variable and repeat its name whenever you use it.

```typescript
const user = {name: "Manuel", age: 36};
console.log(user);
user.age++;
console.log(user);
```

Scope functions don't introduce any new technical capabilities, but they can make your code more concise and readable.

\ <br>


---

# 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://katxupa.gitbook.io/katxupa/get-a-taste-of-katxupa/usage/scope-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.
