Starting ES6 most modern browsers support a function startsWith() that is available to all strings and allows you to check if it starts with another string.
Here are a couple of examples to use this function in JS.
"Hello World!".startsWith("Hello") //returns true
You can also call it on string variables as shown below.
var sample1 = "Hello world"; var sample2 = 'Boy'; console.log(sample1.startsWith(sample2)); // returns false
If you are working with an older browser where startsWith() function is not supported, then you need to use the shim library in your web page, for this purpose.
In this article, we have learnt how to check if a JS string starts with another string.
Forbidden Characters in Windows & Linux Filenames
MySQL Date Format DD/MM/YYYY in SQL Query
How to Fix MySQL Error 1153