Skip to content
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 str.trim() with str.replace() #533

Closed
wants to merge 1 commit into from
Closed

replace str.trim() with str.replace() #533

wants to merge 1 commit into from

Conversation

EugenDueck
Copy link

to make it work in IE8

return str.trim();
return typeof String.prototype.trim === 'function'
? str.trim()
: str.replace(/^\s+|\s+$/g, ''); // e.g. IE 8
Copy link
Contributor

Choose a reason for hiding this comment

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

we might as well just use this one, not like it's slow or anything, and ditch the comment

Copy link
Author

Choose a reason for hiding this comment

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

Agree. In that case, I'd still add a comment like // str.trim() that works in IE8 - the regex is ugly and needs time to parse for a human.

Copy link
Contributor

Choose a reason for hiding this comment

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

just move it into a little function trim(str) {

Copy link
Author

Choose a reason for hiding this comment

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

Sure. E.g. a la http://stackoverflow.com/a/2308157/709537 . I don't care - just make it work! ;)

Copy link
Author

Choose a reason for hiding this comment

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

Btw, Have I already mentioned that mocha rocks? Because it does!

@rauchg
Copy link
Contributor

rauchg commented Aug 7, 2012

+100

@tj
Copy link
Contributor

tj commented Aug 7, 2012

I think we use indexOf() all over too I'll take a look in sec

@tj tj closed this in e82fc05 Aug 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants