Nodejs String Ends With endswith(s)

Here you can find the source of endswith(s)

Method Source Code

String.prototype.endswith = function(s) {
  return (this.match(s+"$")==s)
}

Related

  1. endsWithAny(endings)
    String.prototype.endsWithAny = function (endings) {
      var string = this;
      return endings.some(function (ending) {
        return string.endsWith(ending);
      });
    };
    
  2. endsWithString.prototype.endsWith || (end)
    String.prototype.endsWith = String.prototype.endsWith || function(end){
      return this.substr(this.length - end.length, end.length) === end;
    if (!window.require) {
      window.isBrowser = true;
      window.require = name => {
        if (name === 'path') {
          return {
            sep: '/'
    ...
    
  3. endsWithString.prototype.endsWith || (searchString, length)
    String.prototype.endsWith = String.prototype.endsWith || function(searchString, length) {
        length = typeof length === 'number' && length <  this.length && length >= 0 ? length : this.length;
        return this.substr(length-searchString.length, searchString.length) == searchString;
    console.log("abcd".endsWith("cd", 3));
    
  4. endsWithendsWith(suffix)
    String.prototype.endsWith = function endsWith(suffix) {
      var t = String(suffix);
      var index = this.lastIndexOf(t);
      return (index >= 0) && (index === this.length - t.length);
    };
    
  5. endswith(needle)
    String.prototype.endswith = function (needle) {
       var nedlen = needle.length;
       var haylen = this.length;
       if (nedlen > haylen) {
          return false; 
       return this.lastIndexOf(needle) === haylen-nedlen;
    };
    
  6. endswith(str)
    String.prototype.endswith = function(str)
      return this.slice(this.length - str.length) === str;
    };
    
  7. endswith(str)
    String.prototype.endswith = function(str) {
      return (this.indexOf(str, this.length - str.length) !== -1) ? true: false;
    
  8. endswith(suffix)
    String.prototype.endswith = function(suffix) {
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
    
  9. sl_endsWith(str)
    String.prototype.sl_endsWith = function(str) {
      if (typeof String.prototype.endsWith != 'function') {
        return this.indexOf(str, this.length - str.length - 1) !== -1;
      return this.endsWith(str);
    String.prototype.sl_startsWith = function(str) {
      if (typeof String.prototype.startsWith != 'function') {
        return this.slice(0, str.length) === str;
    ...