Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Iterate through the array and invoke the callback predicate for each element. If the predicate returns a truthy value, push the original element into a result array. Elements that fail the test are skipped, producing a subset of the original array.
Filter tests each element against a predicate and includes only those that pass. Passing Boolean as the callback is a common idiom to remove all falsy values (0, "", null, undefined, false).
Updated Feb 2026