I’ve encountered problems recently when working on a project. Let’s share them with you.
After using servlet to assign value to the html page text box value, use alert to pop up this value. The result shows "undefined". So I naturally used this value to compare with the string "undefined". Unfortunately, the result of the comparison is false.
There is no way, I can only google it and seek the great master.
It turns out that typeof must be used, the writing method is:
The code copy is as follows:
if(typeof(value)=="undefined"){
alert("undefined");
}
This way, the "undefined" will pop up smoothly;
typeof returns a string, and there are six possibilities: "number" "String" "boolean" "object" "function" "undefined"