# #each

This is different than the other functions because it has an opening (`{{#each}}`) and closing (`{{/each}}`) tag and uses an `#` instead of a `$` to prefix the function name. The content within the opening and closing tags is set to the context of the current item in the loop. This means that any variables used within the opening and closing tags are relative to the current item in the loop. If the list of items being looped over is a list of objects, then variable names will represent properties on that object. See example below.

#### Signature

`{{#each array }}{{this}}{{/each}}`

#### Arguments

<table><thead><tr><th width="150">Name</th><th width="272.5333333333333">Description</th><th width="150">Type<select multiple><option value="b0403385da1b4af9a8a894cb7cfa1e88" label="String" color="blue"></option><option value="6a3ca9c830be4cd5a2bcf10d17c44f82" label="Number" color="blue"></option><option value="011b91dfe58a400894b04549ec4f9e02" label="Boolean" color="blue"></option><option value="3c1342f6b38a46e39064bd88015df50d" label="Any" color="blue"></option><option value="cebed7abfeee4c25af96f5c9466ac453" label="String Array" color="blue"></option><option value="8a76c273e1c54778b694497f2a693355" label="Number Array" color="blue"></option><option value="addea9408e6745c9be865b7e946eabca" label="Boolean Array" color="blue"></option><option value="84571f0adb4e4f3daf96174af67f175a" label="Object Array" color="blue"></option><option value="1e4385b940ee4a27a0a2bb649df86e6d" label="Array Array" color="blue"></option></select></th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>array</td><td>List of items to repeat/loop over</td><td><span data-option="cebed7abfeee4c25af96f5c9466ac453">String Array, </span><span data-option="8a76c273e1c54778b694497f2a693355">Number Array, </span><span data-option="addea9408e6745c9be865b7e946eabca">Boolean Array, </span><span data-option="84571f0adb4e4f3daf96174af67f175a">Object Array, </span><span data-option="1e4385b940ee4a27a0a2bb649df86e6d">Array Array</span></td><td>true</td></tr></tbody></table>

#### **Returns**

Content within the opening and closing tags, for each item in the given array/list.

#### **Example - Array of Objects**

In this example we're looping over an array/list of Objects. We can access the properties of the current object in the loop simply by using the name of the property. In the case below, we're displaying the `name` property of each object using the `{{name}}` token. This works because the within the opening and closing tags of the `#each` function, the context is set to the current item in the loop.&#x20;

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

```handlebars
{{#each characters}}{{name}}, {{/each}}
```

{% endtab %}

{% tab title="Data" %}

```json
{
    "characters": [
        { "name": "Wile E. Coyote", "email":"wile.coyote@acme.co" },
        { "name": "Road Runer",     "email":"road.runner@acme.co" }
    ]
}
```

{% endtab %}

{% tab title="Result" %}
Wile E. Coyote, Road Runner&#x20;
{% endtab %}
{% endtabs %}

#### **Example - Array of Strings**

In this example, we're looping over an array/list of Strings. We use the `this` keyword to reference the current item in the loop. `this` always represents the current item in the loop, even when looping over data types other than Strings.

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

```handlebars
{{#each characters}}{{this}}, {{/each}}
```

{% endtab %}

{% tab title="Data" %}

```json
{
    "characters": [ "Wile E. Coyote", "Road Runer" ]
}
```

{% endtab %}

{% tab title="Result" %}
Wile E. Coyote, Road Runner&#x20;
{% endtab %}
{% endtabs %}
