1function IsEmptyOrWhiteSpace(str) {
2 return (str.match(/^\s*$/) || []).length > 0;
3}
1const REGEXP = /^$/;
2
3const validate = (text) => {
4 return REGEXP.test(text);
5}
6
7const isEmpty = validate("");
8const isNotEmpty = validate("x");
9
10console.log(isEmpty); //true
11console.log(isNotEmpty); //false
12