Copy code code as follows:
if (Revalue == Undefined) {
Alert ("UNDEFINED");
}
I found that I couldn't judge, and finally checked the information to use the Typeof method:
ifof (Revalue) == "underfined") {{
Alert ("UNDEFINED");
}
Typeof returns a string, with six possibilities: "Number", "String", "Boolean", "Object", "Function", "Undefined"
3.4 Data type
There are 5 simple data types (also known as basic data types) in ECMascript: Undefined, NULL, Boolean, Number, and String. There is also a complex data type -Object, Object is essentially composed of a set of disorderly fame pairs. ECMAScript does not support any mechanism to create custom types, and all values will eventually be one of the above 6 data types. At first glance, it seems that only 6 types of data types are not enough to represent all data; however, because the ECMAScript data type is dynamic, there is indeed no need to define other data types.
3.4.1 Typeof operator
Given that ECMAScript is a loose type, it is necessary to have a means to detect the data type of a given variable -TYPEOF is an operator responsible for providing information in this area. Using a Typeof operator for one value may return the following string: "UNDEFINED" -If this value is not defined; "Boolean" - if this value is Boolean value; String;
24 Chapter 3 Basic Concept
"" NUMBER "-If this value is value; " Object "-the if this value is an object or null; " function "-the if this value is a function. Below is a few examples of using Typeof operating symbols:
var message = "some string"; alert (typeof message); // "string" alert (typeof (message)); // "string" alert (typeof 95); // "number"
Typeofexample01.htm
These examples show that the number of operations of the Typeof operator can be variables (Message) or numerical noodles. Note that Typeof is an operator rather than a function, so although the brackets in the example can be used, it is not necessary. Sometimes, the Typeof operator will return some confusing but technically correct values. For example, calling Typeof Null will return "Object" because the special value NULL is considered an empty object reference. Safari 5 and previous versions, Chrome 7 and previous versions will return "Function" when calling the Typeof operator on the regular expression, while other browsers will return "Object" in this case.
From a technical point of view, the function is an object in ECMASCRIPT, not a type of data. However, the function does have some special attributes, so it is necessary to distinguish the function and other objects through the Typeof operator.
Copy code code as follows:
Function test1 () {
var message;
if (message) == "underfined")
Alert ("Value is not defined");
else
Alert (Message);
}
var cc = test1;
cc ();