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

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
- Code Assist ID (for the configuration file):
use-string-ends-with
- You can configure custom keyboard shortcuts with this code action kind:
refactor.p42.use-string-ends-with
- This code assist provides refactoring suggestions. Learn how to configure the refactoring suggestion visibility.