Function startsWith

Checks if a value is the start of a source array or string.

startsWith(1)([1, 2, 3]); // => true
startsWith(1)([2, 3, 1]); // => false
startsWith('a')('abc'); // => true
startsWith('a')(['a', 'b', 'c']); // => true
startsWith('b')(['a', 'b', 'c']); // => false
startsWith('b', 1)(['a', 'b', 'c']); // => false
  • Type Parameters

    • V

    Parameters

    • search: V

      The value to search for.

    • OptionalfromIndex: number

      The index to start searching from.

    Returns ((source: V extends string
        ? readonly unknown[] | V<V>
        : readonly unknown[]) => boolean)

      • (source): boolean
      • Parameters

        • source: V extends string
              ? readonly unknown[] | V<V>
              : readonly unknown[]

        Returns boolean