Skip to content

Conversation

@CommanderRoot
Copy link
Contributor

String.prototype.substr() is deprecated so we replace it with functions 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.

}
const type = Object.prototype.toString.call(value);
if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') {
if (type.startsWith('[object') && type.endsWith('Array]')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (type.startsWith('[object') && type.endsWith('Array]')) {
if (type.substring(0, 7) === '[Object]' && type.substring(type.length-6) === 'Array]') {

Bit better performance as starts and endWith

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright I removed the startsWith and endsWith usage

@LeeLenaleee LeeLenaleee added this to the Version 3.8.0 milestone Mar 18, 2022
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 similar functions which aren't deprecated.
Signed-off-by: Tobias Speicher <[email protected]>
@stockiNail
Copy link
Contributor

I have removed my post, sorry. It was in the wrong project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants