You can use the startsWith() method.
Syntax:
string.startsWith(searchString, position)
Example:
const str = "Hello, world!";
console.log(str.startsWith("Hello")); // Output: true
console.log(str.startsWith("world")); // Output: false
console.log(str.startsWith("world", 7)); // Output: true
In the example above, str.startsWith("Hello") returns true because the string str begins with "Hello". The method is case-sensitive, so str.startsWith("hello") would return false. Additionally, str.startsWith("world", 7) returns true because, starting from position 7, the string begins with "world".