Skip to content
𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

Fix for Javascript String.endsWith not supported by IE

Posted on July 11, 2018December 10, 2023 By sastrija

IE doesn’t support some of the String methods which is available with other browsers. String.endsWith is one of them. One of the simple solution is to define its prototype as below.

if (!String.prototype.endsWith) {
  String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
  };
}

Just add above javascript code in to a javascript file (Definitely it should execute before you call String.endsWith in your code) to fix this issue.

 

Related

JavaScript JavaScriptPlugins

Post navigation

Previous post
Next post
©2025 𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ | WordPress Theme by SuperbThemes