JavaScript String endsWith() Method – Fixing error “Object doesn’t support property or method ‘endsWith'” for not supported browsers (e.g. Internet Explorer 10, Internet Explorer 11)

In this article, we will see how we can fix the “Object doesn’t support property or method ‘endsWith’” error which was due to JavaScript (ECMAScript 6) String endsWith() Method not supported on browsers like IE 10, IE 11.

Fixing error “Object doesn’t support property or method ‘endsWith'”

Object doesn’t support property or method ‘endsWith

For fixing this error, you just need to include the  “endsWithForNotSupportedBrowser” method in your JavaScript file (common JavaScript file that is included on all pages) as shown below.

endsWithForNotSupportedBrowser Method: This method check if “String.prototype.endsWith” is available or not and if it is not available it will provide custom implementation for the same.

That’s it. Happy coding !!!

Kapil Khandelwal

Web Developer, Blogger, Microsoft Certified Professional (MCP), DZone's Most Valuable Blogger (MVB)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *