-
Notifications
You must be signed in to change notification settings - Fork 66
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
Fix all uses of String.prototype.substr #408
Comments
Why? Half the web depends on it, and it's often more convenient for parsers than |
I'm not sure why it's more convenient than |
To check that As I understand,
TLDR I don't see how following this deprecation might improve anything. |
Not sure if this was just abandoned on the grounds that
In summary, it seems like switching over is easy, there's a code size win (not a big deal), and maybe a very small performance penalty, but not measurable in real cases. Here's the test case, in case I'm making a systematic error of some sort:
|
I agree that substr() will live forever, but there are ways of writing "modern" JavaScript. .slice() is mirrored by Array, which makes it more consistent. You can still use "var" and "==" all you want, but I wouldn't allow it in a recent PR. I think modernizing a code-base is a good goal to have. It's just confusing to have 3 functions that basically do the same thing. |
See the deprecation warning on MDN.
It looks like we can substitute String.prototype.slice, including in the generated code. Think about edge cases of NaN, negative, and swapped start and end in all cases.
The text was updated successfully, but these errors were encountered: