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

Get rid of String#substr #1

Closed
mathiasbynens opened this Issue Dec 27, 2011 · 7 comments

Comments

Projects
None yet
2 participants
@mathiasbynens
Contributor

mathiasbynens commented Dec 27, 2011

You may want to consider using String#substring or String#slice instead of the non-standard String#substr.

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Dec 27, 2011

Member

I've never met a browser not understanding String.substr() properly. I've been using this method for 5+ years without any problems what so ever?!

Member

rodneyrehm commented Dec 27, 2011

I've never met a browser not understanding String.substr() properly. I've been using this method for 5+ years without any problems what so ever?!

@mathiasbynens

This comment has been minimized.

Show comment
Hide comment
@mathiasbynens

mathiasbynens Dec 27, 2011

Contributor

There may not be problems with it in current browsers, but if there’s a standard, fully specced method (and there are several options here) why not use that one?

Edit: Just to be clear: this was just a friendly heads up, I don’t mean to start a flamewar here.

Contributor

mathiasbynens commented Dec 27, 2011

There may not be problems with it in current browsers, but if there’s a standard, fully specced method (and there are several options here) why not use that one?

Edit: Just to be clear: this was just a friendly heads up, I don’t mean to start a flamewar here.

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Dec 27, 2011

Member

No no no flamewar going on here! I'm just surprised by your intel.
Go ahead and replace those .substr() by whatever you seem fit. I'll be happy to merge…
(heading out to a meeting now ☹)

Member

rodneyrehm commented Dec 27, 2011

No no no flamewar going on here! I'm just surprised by your intel.
Go ahead and replace those .substr() by whatever you seem fit. I'll be happy to merge…
(heading out to a meeting now ☹)

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Dec 27, 2011

Member

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/substr says substr() has been around since Javascript 1.0, although no ECMA specification. I wonder if this really is an issue :/

Member

rodneyrehm commented Dec 27, 2011

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/substr says substr() has been around since Javascript 1.0, although no ECMA specification. I wonder if this really is an issue :/

@mathiasbynens

This comment has been minimized.

Show comment
Hide comment
@mathiasbynens

mathiasbynens Dec 28, 2011

Contributor

I wonder if this really is an issue :/

It’s not — it’s just good practice to use standardized methods where possible.

Contributor

mathiasbynens commented Dec 28, 2011

I wonder if this really is an issue :/

It’s not — it’s just good practice to use standardized methods where possible.

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Dec 28, 2011

Member

I don't disagree. I find it interesting, though, that both standardized methods slice() and substring() take an index as the end-point, rather then number of characters to read (like substr() in any other language I know does…). weird.

Member

rodneyrehm commented Dec 28, 2011

I don't disagree. I find it interesting, though, that both standardized methods slice() and substring() take an index as the end-point, rather then number of characters to read (like substr() in any other language I know does…). weird.

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Dec 28, 2011

Member

Fixed in v1.1.0

Member

rodneyrehm commented Dec 28, 2011

Fixed in v1.1.0

@rodneyrehm rodneyrehm closed this Dec 28, 2011

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