Over a million developers have joined DZone.

Javascript Trim

·

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

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

{{ parent.tldr }}

{{ parent.urlSource.name }}