How would I write the equivalent of C#\'s String.StartsWith in JavaScript?
var haystack = \'hello world\';
var needle = \'he\';
haystack.startsWith(needle)
The string object has methods like startsWith, endsWith and includes methods.
StartsWith checks whether the given string starts at the beginning or not.
endsWith checks whether the given string is at the end or not.
includes checks whether the given string is present at any part or not.
You can find the complete difference between these three in the bellow youtube video
https://www.youtube.com/watch?v=E-hyeSwg0PA