js INDEXOF whitespace code example
Example 1: check whitespace in javascript
if (/\s/.test(str)) {
// It has any kind of whitespace
}
Example 2: js find space in string
if(str.indexOf(' ') >= 0){
console.log("contains spaces");
}
if (/\s/.test(str)) {
// It has any kind of whitespace
}
if(str.indexOf(' ') >= 0){
console.log("contains spaces");
}