Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

nullish coalescing typescript

/* 
Returns its right-hand side operand when its left-hand side operand 
is null or undefined, and otherwise returns its left-hand side operand. 
*/

const checker = null ?? "Hello";
// Hello

const numChecker = 0 ?? "Hello";
// 0

const foo = user.id ?? null;
// user.id if it exists, null if it doesn't
 
PREVIOUS NEXT
Tagged: #nullish #coalescing #typescript
ADD COMMENT
Topic
Name
9+7 =