-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace deprecated String.prototype.substr() #23525
Conversation
It seems the |
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated. Signed-off-by: Tobias Speicher <[email protected]>
This had me puzzled for longer than I want to admit. I fixed it now and the CI tests are passing. |
Why |
Both have their use cases. Both return the same in most cases but can differ if the second parameter is smaller than the first or negative. |
Seems like |
I would say the opposite due to the parameter switching |
Hmm.... Is that why you're using |
That's correct. In both cases the first parameter is >= 0. If the second one would be negative |
Thanks! |
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated. Signed-off-by: Tobias Speicher <[email protected]>
String.prototype.substr() is deprecated so we replace it with String.prototype.slice() which works similarily but isn't deprecated.
.substr() probably isn't going away anytime soon but the change is trivial so it doesn't hurt to do it.