Checks if a string starts with the given prefix.
The string to check.
The prefix to match at the start of the string.
true if the string starts with the prefix, otherwise false.
true
false
1.1.0
startsWith("hello world", "hello"); // truestartsWith("hello world", "world"); // falsestartsWith("typescript", "ts"); // true Copy
startsWith("hello world", "hello"); // truestartsWith("hello world", "world"); // falsestartsWith("typescript", "ts"); // true
Checks if a string starts with the given prefix.