Array filters

Array filters change the output of arrays.

join

Joins the elements of an array with the character passed as the parameter. The result is a single string.

first

Returns the first element of an array.

You can use first with dot notation when you need to use the filter inside a tag.

last

Returns the last element of an array.

You can use last with dot notation when you need to use the filter inside a tag.

Using last on a string returns the last character in the string.

concat

Concatenates (combines) an array with another array. The resulting array contains all the elements of the original arrays. concat will not remove duplicate entries from the concatenated array unless you also use the uniq filter.

You can string together multiple concat filters to combine more than two arrays:

index

Returns the item at the specified index location in an array. Note that array numbering starts from zero, so the first item in an array is referenced with [0].

map

Accepts an array element's attribute as a parameter and creates an array out of each array element's value.

reverse

Reverses the order of the items in an array.

size

Returns the size of a string (the number of characters) or an array (the number of elements).

You can use size with dot notation when you need to use the filter inside a tag.

sort

Sorts the elements of an array by a given attribute of an element in the array.

The order of the sorted array is case-sensitive.

where

Creates an array including only the objects with a given property value, or any truthy value by default.

You can use a property name with where that has no target value when that property is a boolean or truthy. For example, the available property of products.

uniq

Removes any duplicate instances of elements in an array.