# Objects and Arrays

## Objects

You can return objects or arrays to be used by third party modules localization:

keys

```javascript
{
    "tree": {
        "res": "added {{something}}"
    },
    "array": ['a', 'b', 'c']
}
```

sample

{% tabs %}
{% tab title="JavaScript" %}

```javascript
i18next.t('tree', { returnObjects: true, something: 'gold' });
// -> { res: 'added gold' }

i18next.t('array', { returnObjects: true });
// -> ['a', 'b', 'c']
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
i18next.t($ => $.tree, { returnObjects: true, something: 'gold' });
// -> { res: 'added gold' }

i18next.t($ => $.array, { returnObjects: true });
// -> ['a', 'b', 'c']
```

{% endtab %}
{% endtabs %}

The returned value supports interpolation, plurals, nesting, ...

`returnObjects` can be set to true on init.

## Arrays

You can access array values or join them.

keys

```javascript
{
      "arrayJoin": [
        "line1",
        "line2",
        "line3"
      ],
      "arrayJoinWithInterpolation": [
        "you",
        "can",
        "{{myVar}}"
      ],
      "arrayOfObjects": [
        { "name": "tom" },
        { "name": "steve" }
      ]
}
```

sample

{% tabs %}
{% tab title="JavaScript" %}

```javascript
i18next.t('arrayJoin', { joinArrays: '+' });
// -> "line1+line2+line3"

i18next.t('arrayJoinWithInterpolation', { myVar: 'interpolate', joinArrays: ' ' });
// -> "you can interpolate"

i18next.t('arrayOfObjects.0.name');
// -> "tom"
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
i18next.t($ => $.arrayJoin, { joinArrays: '+' });
// -> "line1+line2+line3"

i18next.t($ => $.arrayJoinWithInterpolation, { myVar: 'interpolate', joinArrays: ' ' });
// -> "you can interpolate"

i18next.t($ => $.arrayOfObjects[0].name);
// -> "tom"
```

{% endtab %}
{% endtabs %}

The returned value supports interpolation, plurals, nesting, ...

`joinArrays` can be set to a value on init.


---

# 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://www.i18next.com/translation-function/objects-and-arrays.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.
