Remove all white space from string JavaScript [duplicate] Remove all white space from string JavaScript [duplicate] javascript javascript

Remove all white space from string JavaScript [duplicate]


Use this:

str.replace(/\s+/g, '');

Instead of this:

str.trim()