In JS used in the array, such as multiple names of the same () input, if the dynamic generation (of), the submission of the need to determine whether it is an array. if (document.mylist.length!= "undefined") {} This usage is incorrect.
Correct () is if (typeof (Document.mylist.length)!= "undefined") {}
Or if (!isnan (Document.mylist.length)) {}
typeof () is not defined, the return (of) is "undefined".
The number of operands is typeof (x) = "Number"
String typeof (X) = "string"
Boolean value typeof (X) = "Boolean"
objects, arrays, and Null typeof (X) = "Object"
function typeof (X) = "function"
The typeof operator returns a string that is used to represent the data type (of) the expression.
Possible () strings are: "Number", "string", "Boolean", "Object", "function", and "undefined".
Such as:
Alert (typeof (123));//typeof (123) returns "Number"
Alert (typeof ("123"));//typeof ("123") returns "string"
The typeof operator returns a string that is used to represent the data type (of) the expression.
typeof[() expression[]];
The expression parameter is any expression that needs to find the type information ().
Description
The typeof operator returns the type information as a string. There are six possible typeof return values: "Number," "String," "Boolean," "Object," "function," and "undefined."
The parentheses in the TypeOf syntax are optional. Introduction to the TypeOf operator:
TypeOf is a unary operation, which can be any type of operation before it is placed in one op-count.
The return value is a string that describes the type of the operand.
Do you know the result of the following typeof operation?
typeof (1);
typeof (NaN);
typeof (Number.min_value);
typeof (Infinity);
typeof ("123");
typeof (True);
typeof (Window);
typeof (document);
typeof (NULL);
typeof (Eval);
typeof (Date);
typeof (SSS);
typeof (undefined);
How many do you have?
If you look at it later, not very clear, please see below (understand the people do not have to look down):
typeof is a unary operator, which returns a result that is always a string, and for different operands, it returns a different result.
The specific rules are as follows:
For the operand of a numeric type, the value returned by TypeOf is number. For example: typeof (1), the return value is number.
The above is a regular number, and for unconventional numeric types, the result returns a number. such as typeof (Nan), Nan in
JavaScript represents a special Non-numeric value, although it is itself a numeric type.
In JavaScript, there are several special types of numbers:
Infinity represents Infinity Special value
NaN Special non-numeric value
Number.MAX_VALUE The maximum number that can be represented
Number.min_value can represent the smallest number (closest to 0)
Number.NaN Special non-numeric values
Number.POSITIVE_INFINITY a special value representing positive infinity
Number.negative_infinity represents a special value of negative infinity
The above special type, which is typeof, will result in number.
For a string type, the value returned by TypeOf is String. For example, the value returned by typeof ("123") is a string.
For a Boolean type, the value returned by TypeOf is a Boolean. For example, the value returned by typeof (True) is a Boolean.
The values returned for objects, arrays, and Null are object. For example, typeof (window), typeof (document), typeof (NULL) return values are object.
For a function type, the value returned is a function. For example: typeof (eval), the value returned by typeof (Date) is a function.
If the OP count is undefined (for example, a nonexistent variable, function, or undefined), it will return undefined. For example: typeof (SSS), typeof (undefined) are returned to undefined.
The above mentioned is the entire content of this article, I hope you can enjoy.