Returns the number of times a value appears in a list. A closure might be given which can be used as a shortcut for .filter().len().
This function does not generate a change.
array.count(any)
| Argument | Type | Description | 
|---|---|---|
| any | any | Element to count | 
First item in the list.
This code shows an example using count():
[1, 4, 2, 9, 7, 8, 9, 3, 1].count(9);
Return value in JSON format
2
Another example using a callback:
// Count the values larger than 5
[1, 4, 2, 9, 7, 8, 9, 3, 1].count(|x| x > 5);
4