Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check null or undefined in javascript

//check for null or undefined with nullish coalescing operator
let value = null ?? "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: #check #null #undefined #javascript
ADD COMMENT
Topic
Name
9+4 =