• Returns the first not nil element in the given array, or null if all elements are nil

    Parameters

    • Optionalarray: null | any[] | readonly any[]

      the array to check

    Returns any

    the first not nil element in the given array, or null if all elements are nil

    firstNotNil([null, undefined, 'foo', 'bar', {}]);    // 'foo'