Skip to content

Determines whether a string begins with the characters of a specified string.

License

Notifications You must be signed in to change notification settings

Xotic750/string-starts-with-x

Repository files navigation

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

string-starts-with-x

Determines whether a string begins with the characters of a specified string.

module.exportsboolean

This method determines whether a string begins with the characters of a specified string, returning true or false as appropriate.

Kind: Exported member
Returns: boolean - true if the given characters are found at the beginning of the string; otherwise, false.
Throws:

  • TypeError If string is null or undefined.
  • TypeError If searchString is a RegExp.
Param Type Description
string string The string to be search.
searchString string The characters to be searched for at the start of this string.
[position] number The position in this string at which to begin searching for searchString; defaults to 0.

Example

import startsWith from 'string-starts-with-x';

const str = 'To be, or not to be, that is the question.';

startsWith(str, 'To be'); // true
startsWith(str, 'not to be'); // false
startsWith(str, 'not to be', 10); // true

About

Determines whether a string begins with the characters of a specified string.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published