if(document.mylist.length != "undefined" ) {} This usage is incorrect.
The correct one is if( typeof(document.mylist.length) != "undefined" ) {}
or if( !isNaN(document.mylist.length) ) {}
The operand of typeof is not defined, and the returned value is "undefined".
The operand is a number typeof(x) = "number"
String typeof (x) = "string"
Boolean typeof(x) = "boolean"
Object, array and null typeof(x) = "object"
Function typeof(x) = "function" typeof operator returns a string representing the data type of the expression.
Possible strings are: "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 representing the data type of the expression.
typeof[()expression[]] ;
expression parameter is any expression for which type information needs to be found.
Script Home www.jb51.net For more javascript information, please visit
Explanation
The typeof operator returns type information as a string. There are six possible return values of typeof: "number," "string," "boolean," "object," "function," and "undefined."
The parentheses in the typeof syntax are optional.