If (document. mylist. length! = "Undefined") {} This usage is incorrect.
Correct is if (typeof (document. mylist. length )! = "Undefined "){}
Or if (! IsNaN (document. mylist. length )){}
The number of typeof operations is undefined, and "undefined" is returned ".
Number of operations: number typeof (x) = "number"
String typeof (x) = "string"
Boolean value typeof (x) = "boolean"
Object, array, and null typeof (x) = "object"
Function typeof (x) = "function"
The typeof operator returns a string that represents the Data Type of the expression.
Possible strings include: "number", "string", "boolean", "object", "function", and "undefined ".
For example:
Alert (typeof (123); // typeof (123) returns "number"
Alert (typeof ("123"); // typeof ("123") returns "string"
Typeof Operator
Returns a string that represents the expression's data type.
Typeof [() expression [];
The expression parameter is an arbitrary expression that needs to be searched for type information.
For more javascript Information, visit www.jb51.net.
Description
The typeof operator returns the type information as a string. There are six possible types of typeof return values: "number," "string," "boolean," "object," "function," and "undefined ."
Parentheses in the typeof syntax are optional.