Created by bdukesLinked to 75.3m issues across 157 teams
You can check for an empty/undefined/null string in JavaScript using truthy and falsy checks.
For example, you can use the Boolean()
function to check if a string is empty/undefined/null:
let str = ''; let result = Boolean(str); console.log(result); // Output: false
In the example above, the Boolean()
function returns false
because the string str
is empty.
Contributor
Teams
157