A conceptual explanation:
undefined is one of the five original classes defined in the JavaScript language, in other words, undefined is not a program error, but a value allowed by the program.
not defined is a bug that JavaScript bursts when it runs our JavaScript code and encounters a variable that is not defined for operation.
So here's the problem: in many JavaScript tutorials, javascript variables are introduced, even if they are not defined, and can be used directly, but be aware that this use refers to the ability to be assigned, but not to be evaluated. See an example
var temp;
TEMP2 = 123;
alert (TEMP2);
Temp3 = temp4+1;
alert (Temp3);
In the above code, the first alert can have a normal pop-up window of 123, but the second alert will not be executed because it is not allowed to use an undefined temp4 to operate.
let's look at an example:
var temp;
alert (temp);
alert (typeof temp);
alert (typeof temp2);
alert (temp==undefined);
alert (temp2==undefined);
in this example:
The first, second, and third alert can pop up the hint undefined, but in fact the meaning of these three undefined is not the same. In JavaScript, undefined is a class, the class has only one value is undefined, the first alert pops up is the value undefined, the second and the third pop up is undefined the class name.
A fourth alert will pop up true, which is a judgment.
The fifth alert will not pop up because of an error. The error here is that the operation is performed using a variable that is not defined. The error that was TEMP2 was not defined; (different browsers may say differently)
What is the difference between not defined and undefined in javascript?