How to remove white spaces from a string

Today at work, I happened to write a function that removes white spaces from a string. After trying different ways using: loops, array indexer, or regex, I came up with the shortest way using regular expression to share with you:

var str = ” — This is %$# ‘’ a test string ha    hee hhhoo    1   22 33  “;
str = str.replace(/s/g, ”);
// str is now –Thisis%$#”ateststringhaheehhhoo12233

,