DEV Community

yogesh2019
yogesh2019

Posted on

Difference bet null and undefined

Number 1

null is intentionally set and means nothing
undefined means that the boxes exist but not filled

Number 2

null has a type of object
undefined gives us a type of undefined

Number 3

console.log(isNaN(1+null)) gives false
console.log(isNaN(1+undefined)) gives true

Number 4

Any variable which is not initialized and a method which doesn't have any return type, By default it is assigned a type of "unassigned".

Top comments (0)