Hi Friends 👋,
Welcome To Infinitbility! ❤️
To check blank value in typeScript, use if...else
statement it will handle all falsy value like undefined
, null
, empty
, blank
and etc.
Let’s see short example to use if...else
with value
to check blank value in in typeScript.
if(value){
}
Today, I’m going to show you How do I check blank value in typeScript, as above mentioned, I’m going to use the above-mentioned if...else
statement.
Let’s start today’s tutorial how do you check blank value in typeScript?
TypeScript check blank value example
Here, we will take string variable with some data and use if...else
statement to check blank value.
let value: any = "";
if(value){
console.log("value is have data")
} else {
console.log("value is a blank")
}
if(value == ""){
console.log("value is a blank")
}
I hope it helps you, All the best 👍.