Node.js examples for String:Search
Indicates whether or not this string starts/ends with the specified string.
/**//from www. j a va2 s .co m * Indicates whether or not this string starts with the specified string. * @param {Object} string */ String.prototype.startsWith = function(string){ if (!string) return false; return this.indexOf(string) == 0; } /** * Indicates whether or not this string ends with the specified string. * @param {Object} string */ String.prototype.endsWith = function(string){ if (!string || string.length > this.length) return false; return this.indexOf(string) == this.length - string.length; }