Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nullish coalescing operator in javascript

//nullish coalescing operator in js
Expression:
	Left ?? Right
if left is null or undefined , then Right will be the value

let value = null ?? "Oops.. null or undefined";
console.log(value) //Oops.. null or undefined

value = undefined ?? "Oops.. null or undefined";
console.log(value) //Oops.. null or undefined

value = 25 ?? "Oops.. null or undefined";
console.log(value) // 25

value = "" ?? "Oops.. null or undefined";
console.log(value) // ""
 
PREVIOUS NEXT
Tagged: #nullish #coalescing #operator #javascript
ADD COMMENT
Topic
Name
8+6 =