js detect whitespaces code example Example: check whitespace in javascript Click to copyif (/\s/.test(str)) { // It has any kind of whitespace }