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

Node.js examples for String:String Start

Description

Returns whether or not the string ends with a particular value

Demo Code


/**//from www  .  j  av  a 2  s  . com
 * Returns whether or not the string ends 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.endsWith = String.prototype.endsWith || function(value) {
  return this.substring(this.length-value.length,this.length) === value;
};

Related Tutorials