1. Determine whether it is an array type 2. determine whether it is a string type
3. Determine whether the data type is Numeric.
4. Determine if it is of the date type
5. determine whether it is a function.
6. Determine whether the object is used
1. Determine whether it is an array type.
Linenum
<SCRIPT type = "text/JavaScript">
// <! [CDATA [
VaR A = [0];
Document. Write (isarray (A), '<br/> ');
Function isarray (OBJ ){
Return (typeof OBJ = 'object') & obj. constructor = array;
}
//]>
</SCRIPT>
2. Determine whether the string type is used.
Linenum
<SCRIPT type = "text/JavaScript">
// <! [CDATA [
Document. Write (isstring ('test'), '<br/> ');
Document. Write (isstring (10), '<br/> ');
Function isstring (STR ){
Return (typeof STR = 'string') & Str. constructor = string;
}
//]>
</SCRIPT>
3. Determine whether the data type is Numeric.
Linenum
<SCRIPT type = "text/JavaScript">
// <! [CDATA [
Document. Write (isnumber ('test'), '<br/> ');
Document. Write (isnumber (10), '<br/> ');
Function isnumber (OBJ ){
Return (typeof OBJ = 'number') & obj. constructor = number;
}
//]>
</SCRIPT>
4. Determine if it is of the date type
Linenum
<SCRIPT type = "text/JavaScript">
// <! [CDATA [
Document. Write (isdate (new date (), '<br/> ');
Document. Write (isdate (10), '<br/> ');
Function isdate (OBJ ){
Return (typeof OBJ = 'object') & obj. constructor = date;
}
//]>
</SCRIPT>
5. determine whether it is a function.
Linenum
<SCRIPT type = "text/JavaScript">
// <! [CDATA [
Document. Write (isfunction (function test () {}), '<br/> ');
Document. Write (isfunction (10), '<br/> ');
Function isfunction (OBJ ){
Return (typeof OBJ = 'function') & obj. constructor = function;
}
//]>
</SCRIPT>
6. Determine whether the object is used
<SCRIPT type = "text/JavaScript">
Linenum
// <! [CDATA [
Document. Write (isobject (new object (), '<br/> ');
Document. Write (isobject (10), '<br/> ');
Function isobject (OBJ ){
Return (typeof OBJ = 'object') & obj. constructor = object;
}
//]>
</SCRIPT>
Purpose:
Very powerful and practical. It can be used to determine whether the JSON string returned by the server is legal. if the server returns an array-type JSON string, the object after eval () is not an array, which indicates that the server has encountered an error.