# keys

The `keys` function returns the keys of a map or the indices of a slice.

It is useful for inspecting the structure of data, iterating over fields, or extracting available paths.

#### Syntax

Chained form:

```
<value>.keys()
```

#### Arguments

This function does not accept any arguments.

#### Examples

**Map keys**

```
{"name":"Tom","age":30}.keys()
```

**Output**

```
["name","age"]
```

**Slice indices**

```
["a","b","c"].keys()
```

**Output**

```
[0,1,2]
```

**Nested usage**

```
{"user":{"name":"Tom","age":30}}.user.keys()
```

**Output**

```
["name","age"]
```

#### Notes

* When used on a **map**, `keys` returns a slice of strings.
* When used on a **slice**, `keys` returns a slice of integers representing indices.
* The order of keys for maps is not guaranteed.
* This function cannot be used on scalar values (e.g. strings, numbers, booleans).

#### Errors

* Returns an error if used on a non-map and non-slice value.


---

# 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://daseldocs.tomwright.me/functions/keys.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.
