Skip to main content

doesStartWith()

doesStartWith(prefix): (input) => boolean

Creates a predicate function that determines if a string starts with a specific prefix.

Parameters

prefix

string

The substring to use as the prefix

Returns

(input): boolean

Parameters

input

string

Returns

boolean

Remarks

  • Pure function with no side effects
  • Case-sensitive comparison
  • Uses String.prototype.startsWith() internally
  • Useful for array filtering and functional programming

Example

const startsWithHttp = doesStartWith('http');
startsWithHttp('https://example.com'); // true
startsWithHttp('ftp://example.com'); // false