How To trim() in Javascript

How To trim() in Javascript

Note: This article will be emailed to your friend.

Javascript doesn’t natively support trim on strings. It is however very easy to implement with regular expressions.

function trim (str) {
str = this != window? this : str;
return str.replace(/^\s+/, ”).replace(/\s+$/, ”);
}

[...]

Read the rest of this article (63 words)

Please fill in the following fields

* - Required

Your Name: *

Your E-Mail: *

Your Remarks:

Friend's Name: *

Friend's E-Mail: *

Protected by Comment Guard Pro