How to check whether a string variable is empty or null in Javascript?
javascript if string empty
// Test whether strValue is empty or is None
if (strValue) {
//do something
}
// Test wheter strValue is empty, but not None
if (strValue === "") {
//do something
}
js if string not empty
if (strValue === "") {
//...
}
Example 2
function isEmpty(str) {
return (!str || str.length === 0 );
}