Javascript basics: difference between undefined and null

Hello,

I followed the freecodecamp tutorial for javascript on youtube.
When I just declare a variable and try to print it in console, I get undefined and not null as mentioned in the tutorial.
Eg. var a;
console.log(a)
o/p - undefined and not null
Am I missing something?

undefined means a variable has been declared but not given a defined value. In your example, the value of a is undefined, not null.

null is used to represent “no value”. It’s a defined value - in programming there needs to be some way to represent the non-existence of a value, and in JS that’s what null is for. To make a have the value of null, you literally need to assign the value null to it: a = null

Oh, alright. This looks informative. Thanks!

thnaks for this information