Answers for "typescript declare variable undefined"

0

typescript declare variable undefined

let age: number | undefined;
age = 18;

if (age) {
  // This will run because age is not null or undefined
}

age = undefined;

if (age) {
  // This will not run because age is undefined
}

// If you want to do something when it is undefined
if (age === undefined) {
  // This will run because age is undefined
}
Posted by: Guest on September-15-2021
0

string undefined typescript

let name1:string = person.name!; 
//                            ^ note the exclamation mark here
Posted by: Guest on June-10-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language