One
Often in the JS to use the array, such as multiple names of the same input, if dynamically generated, the submission will 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)) {}
The operand of typeof is undefined, and the return 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"
Two
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 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."
Parentheses in the typeof syntax are optional.
The usage of typeof in JS