# forloop

> The forloop Liquid object, which exposes the state of the surrounding for loop in a Shoplazza theme, such as the current index and whether it is the last pass.

Information about a parent [for loop](../tags/iteration#for).

| Properties | Type    | Description                                                                   |
| :--------- | :------ | :---------------------------------------------------------------------------- |
| `first`    | boolean | Returns `true` if the current iteration is the first. Returns `false` if not. |
| `last`     | boolean | Returns `true` if the current iteration is the last. Returns `false` if not.  |
| `index`    | number  | The 1-based index of the current iteration.                                   |
| `index0`   | number  | The 0-based index of the current iteration.                                   |
| `length`   | number  | The total number of iterations in the loop.                                   |
| `rindex`   | number  | The 1-based index of the current iteration, in reverse order.                 |
| `rindex0`  | number  | The 0-based index of the current iteration, in reverse order.                 |

```json title="Object"
{
  "first":true,
  "last":false,
  "index":1,
  "index0":0,
  "rindex":4,
  "rindex0":3,
  "length":4
}
```

**use the`forloop` object**

```liquid title="Code"
{% for i in (1..5) %}
  {% if forloop.length > 0 %}
    {{ i }}{% unless forloop.last %},{% endunless %}
  {% endif %}
{% endfor %}
```

```html title="Output"
1, 2, 3, 4, 5
```
