# Using array predicates

An array predicate allows you to filter items by their position in the current context.

This predicate is used after a location step, in square brackets, to return one or more items based on their index. The table below describes the syntax to use.

| Syntax | Description | Examples |
| --- | --- | --- |
| [index] | Returns the item with the specified index. | <ul> <li><span>.customer[0]</span> returns the first item in the                  <span>customer</span> array.</li> <li><span>.customer[-1]</span> returns the last item in the                  <span>customer</span> array.</li> </ul> |
| [index:] | Returns items whose index is equal to or greater than the specified<br>index. | <ul> <li><span>.customer[-3:]</span> returns the last three items in the                  <span>customer</span> array.</li> <li><span>.customer[2:]</span> returns all items in the <span>customer</span>                array starting from the third one.</li> </ul> |
| [:index] | Returns items whose index is equal to or lesser than the specified index.<br><br>Information noteNote: When used with a negative number, this syntax subtracts the specified<br>value from the size of the array and compares the result to the indexes in the array.<br>For example, for an array with 5 items, [:-2] returns all items whose<br>index is lesser than or equal to 5-2, so it returns indexes 0 to 3<br>and only ignores the last item, which has the index 4. | <ul> <li><span>.customer[:5]</span> returns the first six items in the                  <span>customer</span> array.</li> <li><span>.customer[:-2]</span> returns all items in the <span>customer</span>                array except for the last one.</li> </ul> |
| [start\_index:end\_index] | Returns items between the first index and the second index. Both the start index<br>and the end indexes are included in the result. | <ul> <li><span>.customer[2:5]</span> returns the third, fourth, fifth and sixth items                in the <span>customer</span> array.</li> <li><span>.customer[-3:-2]</span> returns the third and second items from the end                of the <span>customer</span> array.</li> </ul> |
| [\*] | Returns all items in the current context. | .customer[\*] returns all items in the customer<br>array. |