Skip to content

JSArray.Every

boxgaming edited this page Jul 25, 2026 · 5 revisions

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

Syntax

result = JSArray.Every ( 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)

Print JSArray.Every(numbers, @Test1)
Print JSArray.Every(numbers, @Test2)


Function Test1 (element)
    Test1 = element > 15
End Function

Function Test2 (element)
    Test2 = element < 30
End Function

Output

0
-1

See Also

JSArray.Create
Javascript - Array.every()

Clone this wiki locally