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 learned about this string library:
http://stringjs.com/
Include the js file and then use the S
variable like this:
S('hi there').endsWith('hi there')
It can also be used in NodeJS by installing it:
npm install string
Then requiring it as the S
variable:
var S = require('string');
The web page also has links to alternate string libraries, if this one doesn't take your fancy.