Not defined and Undefined” in JS are not the same thing. Let’s discuss what they actually means.

Not defined: It occurs when you consoled the variable without defining it. Moving deep down, To be consoled it must be in the memory space right ! so, without defining any variable, how would it supposed to take the memory space. So, this will cause the error ‘not defined’.

Undefined: Undefined occurs when you have consoled the variable before it is initialized. Moving deep down, When you console any variable before initializing, In Javascript memory the variable has already taken up the space for that variable name with no value in it, but undefined is initialized to that variable.