Nodejs String Ends With endsWith(end)

Here you can find the source of endsWith(end)

Method Source Code

// ( 9 ) String.endsWith()
String.prototype.endsWith = function(end) {
    if(end == '') return true;
    else if(end == null || end.length > this.length) return false;
    else return this.indexOf(end, this.length - end.length) !== -1;
}

Related

  1. ends( other )
    String.prototype.ends = function( other ){
      if( !other )return false
      var endlen   = this.length
      var otherlen = other.length
      if( !endlen || endlen > otherlen ){ return false }
      return other.substr( 0, otherlen - endlen) + this == other
    function str_ends( that, other ){
      if( !other )return false
    ...
    
  2. endsWith( keyword, ignoreCase)
    jCube.String.endsWith  =
    String.prototype.endsWith  = function( keyword, ignoreCase) {
      var _string  = this;
      if ( ignoreCase == true ) {
        _string  = _string.toLowerCase();
        keyword  = keyword.toLowerCase();
      return _string.substring( _string.length-keyword.length) == keyword;
    
  3. endsWith( str )
    String.prototype.endsWith = function( str ) {
        if( str.length > this.length ) {
            return false;
        return( String( this ).substr( this.length - str.length, this.length ) == str );
    };
    
  4. endsWith( value, ignoreCase )
    String.prototype.endsWith = function( value, ignoreCase )
      var L1 = this.length ;
      var L2 = value.length ;
      if ( L2 > L1 )
        return false ;
      if ( ignoreCase )
        var oRegex = new RegExp( value + '$' , 'i' ) ;
    ...
    
  5. endsWith(end)
    String.prototype.endsWith = function(end) {
      return this.indexOf(end) == this.length-end.length;
    };
    
  6. endsWith(matchstring)
    String.prototype.endsWith = function (matchstring) {
        return reverse(this).startsWith(reverse(matchstring));
    
  7. endsWith(needle)
    String.prototype.endsWith = function(needle) {
        return this.slice(-needle.length) == needle;
    
  8. endsWith(pattern)
    String.prototype.endsWith = function(pattern) {
      var d = this.length - pattern.length;
      return d >= 0 && this.lastIndexOf(pattern) === d;
    };
    
  9. endsWith(pattern)
    String.prototype.endsWith = function(pattern) {
        return (this.substr(this.length - pattern.length, pattern.length) == pattern);
    };