Standard built-ins
Array.prototype.filter()
Collects present elements whose callback result is truthy, in original relative order. Ordinary holes are skipped and selected object values remain shared.
Formal Syntax & Structure
javascript syntaxjavascript
array.filter(callback, thisArg?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| callback | function | Tests each present value with value, index, source. |
| thisArg | any | Optional this value for ordinary callback functions. |
Return Value
Array
Dense array of qualifying elements for an ordinary receiver.
Working Example
Example Snippetjavascript
console.log([1,4,6].filter(n=>n>3).join(","));