Posted By

davidwaterston on 03/15/12



Versions (?)

Case-sensitive 'Starts With'

 / Published in: JavaScript

A simple Javascript function to tell if one string starts with another.


if (myString.startsWith("anything") { do something… }

NOTE: As always, make sure this is defined before it is used!

  1. if (typeof String.prototype.startsWith != 'function') {
  2. String.prototype.startsWith = function(str) {
  3. return (this.lastIndexOf(str, 0) === 0);
  4. };
  5. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: cheapbags on March 16, 2012

I just have the same idea, Are you searching for finest Cheap Hermes Birkin ? buy Original Leather Hermes Bags Online Sale, 100% guaranteed, you could come to our store and find one handbags you love. and we will tell you Hermes latest news from Hermes Birkin blog.

You need to login to post a comment.