π Prefer String#slice() over String#substr() and String#substring().
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
String#substr() and String#substring() are the two lesser known legacy ways to slice a string. It's better to use String#slice() as it's a more popular option with clearer behavior that has a consistent Array counterpart.
// β
foo.substr(start, length);
// β
foo.substring(indexStart, indexEnd);
// β
foo.slice(beginIndex, endIndex);