How can I remove all the white space from a given string.
Say:
var str = " abc de fog ";
str.trim();
Gives abc de fog
AND NOT abcdefog
, which I want.
How can I get all the white space removed using JavaScript?
Use this:
str.replace(/\s+/g, '');
Instead of this:
str.trim()