Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to check if a string contains only spaces in javascript

let str = "    ";
if (!str.replace(/s/g, "").length) {
  console.log("string only contains whitespace (ie. spaces, tabs or line breaks)");
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #string #spaces #javascript
ADD COMMENT
Topic
Name
7+7 =