node-lib

@wtasnorg/node-lib


@wtasnorg/node-lib / hasPrefixString

Function: hasPrefixString()

hasPrefixString(s, prefix): boolean

Defined in: src/strings.ts:448

HasPrefix reports whether the string s begins with prefix.

Parameters

s

string

Input string.

prefix

string

Prefix to check.

Returns

boolean

True if s starts with prefix.

Example

hasPrefix("Gopher", "Go"); // true
hasPrefix("Gopher", "");   // true — empty prefix always matches
hasPrefix("Gopher", "X");  // false
hasPrefix("ab", "abc");    // false — prefix longer than s