Answers for "typescript default value if null"

0

typescript default value if null

/* Use || operator to assign a default value whence the first variable
evaluates to a 'falsy' value
	- Example with strings (you can replace string with any type T) */

let x: string | null = null;
let y: string = x || "My default value"
Posted by: Guest on February-15-2022

Code answers related to "typescript default value if null"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language