Array.filter(filter) Last updated: 24. Jan 2023
Returns the items in an array that matches the filter function.
Parameters
Name | Type | Description |
---|---|---|
filter | function | Bool function that filters out items in the array. |
Returns
An array of items that match the specified filter.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.const words = ["abcdefg", "efgha", "abc123"];
const result = words.filter(word => word.startsWith("abc"));
write(JSON.stringify(result));
Output
The JS code above produces the output shown below:["abcdefg","abc123"]