This article mainly introduces the correct way to determine the undefined type in JavaScript. I believe many students will use the wrong method when encountering this problem. The correct method is also very simple. Friends in need can refer to it
The code is as follows:
if (reValue== undefined){ alert("undefined"); }
I found that I couldn’t determine it. Finally, I checked the information and needed to use the typeof
method:
The code is as follows:
if (typeof(reValue) == "undefined") { alert("undefined"); }
typeof returns a string, there are six possibilities: "number", "string", "boolean", "object", "function", "undefined"
More For more related tutorials, please visit JavaScript Basics Tutorial