javascript whitespace code example

Example 1: whitespace in html

<!--   Add leading white space in front of text  -->

&nbsp;Hello World

<!--    Output:   ' Hello World'    -->

Example 2: check whitespace in javascript

if (/\s/.test(str)) {
    // It has any kind of whitespace
}

Example 3: what is whitespace javascript

Whitespace is empty space (without any visual representation)
 on screen. Examples of whitespace characters include 
 space characters, tabs, and line break characters.