Hi Friends đź‘‹,

Welcome To Infinitbility! ❤️

To check blank space in typeScript, use if...else statement with trim() method it will handle all falsy value like undefined, null, empty, blank and etc.

Let’s see short example to use if...else with trim() method to check blank space in in typeScript.

if(value.trim()){

}

Today, I’m going to show you How do I check blank space 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 space in typeScript?

TypeScript check blank space example

Here, we will take string variable with some data and use if...else statement to check blank space.

let value: any = "   ";

if(value.trim()){
  console.log("value is have data")
} else {
  console.log("value is a blank")
}

if(value.trim() == ""){
  console.log("value is a blank")
}

I hope it helps you, All the best đź‘Ť.