Function every

  • Checks if predicate returns truthy for all elements of array. Iteration is stopped once predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

    Note: This method returns true for empty arrays because everything is true of elements of empty arrays.

    Type Parameters

    • T

    Parameters

    • array: T[]

      The array to iterate over.

    • predicate: ListIterator<T, boolean>

      The function invoked per iteration.

    Returns boolean

    Returns true if all elements pass the predicate check, else false.

    5.0.0

    every([true, 1, null, 'yes'], Boolean)
    // => false