Open CommanderRoot opened 2 years ago
This looks good! Thanks for the contribution.
One thing I noticed was your two replacements of .substr
with .substring
still contain the exact same args, even though the two functions treat the second arg differently. Though, from a quick read of the surrounding code, it seems like the original author might have thought .substr
works the same as .substring
(or just confused them), hence that second arg doesn't need to be changed? Is that how you interpreted it?
The reason I used substring()
instead of slice()
in these instances is because the second parameter is normally positive but it could be negative.
Example:
"0123456789".substr(0, -1) == ""
"0123456789".substring(0, -1) == ""
"0123456789".slice(0, -1) == "012345678"
So to replicate the current behaviour I used substring()
.
String.prototype.substr() is deprecated so we replace it with String.prototype.slice() or String.prototype.substring() which work similarily but aren't deprecated. .substr() probably isn't going away anytime soon but the change is trivial so it doesn't hurt to do it.