Returns whether or not the string begins with a particular value - Node.js String

Node.js examples for String:String Start

Description

Returns whether or not the string begins with a particular value

Demo Code


/**//from   www.j a va 2s  .c om
 * Returns whether or not the string begins with a particular value
 * @version 1.0.0
 * @date March 24, 2011
 * @package jquery-sparkle {@link http://www.balupton/projects/jquery-sparkle}
 * @author Benjamin "balupton" Lupton {@link http://www.balupton.com}
 * @copyright (c) 2011 Benjamin Arthur Lupton {@link http://www.balupton.com}
 * @license MIT License {@link http://creativecommons.org/licenses/MIT/}
 */
String.prototype.beginsWith = String.prototype.beginsWith || function(value) {
  return this.substring(0,value.length) === value;
};

Related Tutorials