Determines if a haystack string starts with a specified needle substring, case-insensitive.
The main string to check.
The substring to check if the main string starts with.
True if the main string starts with the specified substring, false otherwise.
const haystack = 'Hello, world!';startsWith(haystack, 'hello'); // returns true Copy
const haystack = 'Hello, world!';startsWith(haystack, 'hello'); // returns true
Use the built-in startsWith, lowercasing both strings for the same case-insensitive check: haystack.toLowerCase().startsWith(needle.toLowerCase()). Will be removed in goldies 6.0.
startsWith
haystack.toLowerCase().startsWith(needle.toLowerCase())
Determines if a haystack string starts with a specified needle substring, case-insensitive.