3
Reply

What is the difference between undefined and null in JavaScript?

Sanjay Dixit

Sanjay Dixit

11y
800
0
Reply

    1. console.log(a); /* undefined */var b;2. console.log(b); /* null */

    In JavaScript, 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:

    undefined is a type itself (undefined) while null is an object.