Search
 
SCRIPT & CODE EXAMPLE
 

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)");
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove element by class 
Javascript ::  
Javascript ::  
:: loop through key value pairs js 
::  
Javascript :: set width screen angular 
:: nodejs command line arguments 
::  
:: node format variable in string 
Javascript :: jquery continue in loop each 
Javascript ::  
Javascript :: html string to html 
::  
::  
::  
::  
Javascript :: javascript detect dark mode 
Javascript ::  
Javascript :: javascript remove space from two side of string 
:: jimp get image size 
::  
::  
Javascript :: select all children javascript 
::  
Javascript ::  
Javascript :: change onclick attribute with javascrip 
Javascript ::  
::  
::  
:: how to use session using javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =