typescript check if string is undefined or empty code example
Example 1: javascript check if object is null or empty
if (typeof value !== 'undefined' && value) {
};
Example 2: javascript check if undefined or null or empty string
if (myString) {
}
Example 3: typescript if string is null or empty
function empty(e) {
switch (e) {
case "":
case 0:
case "0":
case null:
case false:
case typeof(e) == "undefined":
return true;
default:
return false;
}
}
empty(null)
empty(0)
empty(7)
empty("")
empty((function() {
return ""
}))