StringprototypestartsWithsearchString
StringprototypestartsWithsearchString refers to the JavaScript method String.prototype.startsWith, which checks whether a string begins with a given substring. It returns a boolean: true if the string starts with searchString, otherwise false.
Syntax: String.prototype.startsWith(searchString[, position]). The searchString is converted to a string. position is optional and specifies the
Parameters: searchString is the substring to look for at the start of the string. position allows offsetting
Return value: A boolean indicating whether the string starts with searchString at the given position.
Examples: 'abcdef'.startsWith('abc') returns true. 'abcdef'.startsWith('bc', 1) returns true. 'abcdef'.startsWith('def', 3) returns true. 'abc'.startsWith('', 2) returns true.
Compatibility and polyfills: Introduced in ES2015 (ES6) and supported in all modern browsers and Node.js. In
See also: includes, endsWith, indexOf.
This article describes the behavior and usage of StringprototypestartsWithsearchString, aligning with the standard JavaScript String.prototype.startsWith method.