Skip to content

JSArray.Filter

boxgaming edited this page Jul 25, 2026 · 2 revisions

Returns false if it finds an element in the array that does not satisfy the provided testing function. Otherwise, it returns true.

Syntax

filteredArray = JSArray.Filter ( a, callbackFn )

Parameters

  • The a parameter contains the native Javascript array on which the operation will be performed.
  • The callbackFn parameter specifies a function to execute for each element in the array. It should return a true value to indicate the element passes the test, and a false value otherwise. The function is called with the following arguments:
    • element
      The current element being processed in the array.
    • index
      The index of the current element being processed in the array.
    • array
      The array every() was called upon.

Example

Import JSArray From "lib/lang/array.bas"

Dim numbers As Object
numbers = JSArray.Create(5, 27, 18, 9, 4, 22, 20)

Dim filtered As Object
filtered = JSArray.Filter(numbers, @RangeFilter)

Print filtered

Function RangeFilter (element)
    RangeFilter = element >= 15 And element <= 25
End Function

Output

18,22,20

See Also

JSArray.Create
Javascript - Array.filter()

Clone this wiki locally