null vs undefined

There's a difference between null and undefined. undefined means a variable has been declared but has not yet been assigned a value. null is an assignment value; it can be assigned to a variable as a representation of no value. So I should use null to represent no value, such as

interface ApiReponse {  
 createdAt: string | null}  

This picture explains the concept visually.

Would you like to connect? Subscribe via email or RSS , or follow me on Twitter!