How would I write the equivalent of C#\'s String.StartsWith in JavaScript?
var haystack = \'hello world\'; var needle = \'he\'; haystack.startsWith(needle)
I just wanted to add my opinion about this.
I think we can just use like this:
var haystack = 'hello world'; var needle = 'he'; if (haystack.indexOf(needle) == 0) { // Code if string starts with this substring }