if (/\s/.test(str)) { // It has any kind of whitespace }
Whitespace is empty space (without any visual representation) on screen. Examples of whitespace characters include space characters, tabs, and line break characters.