Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Javascript Trim

DZone's Guide to

Javascript Trim

·
Free Resource

// Removes leading and ending whitespaces, nbsps
function trim(str) {
    return str.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '');
}
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}