whitespace in string javascript code example
Example 1: check whitespace in javascript
if (/\s/.test(str)) {
// It has any kind of whitespace
}
Example 2: remove whitespace javascript
var str = " Some text ";
str.trim();
if (/\s/.test(str)) {
// It has any kind of whitespace
}
var str = " Some text ";
str.trim();