Use string.endsWith()

string.endsWith() checks if a string ends with another string.

Use string.endsWith()

String.prototype.endsWith() checks if a string ends with another string.

This refactoring replaces index-based single-character comparison with endsWidth, e.g. s[s.length - 1] === '/' becomes s.endsWith('/').

What do I need to consider?

String.endsWith is an ES20215 feature. It is supported on all modern browsers, but for older browsers polyfilling might be required (browser support).

Configuration

Related Code Assists

Learn More

Available In