if( type(document.mylist.length) != "undefined" ) {} 或 if( !isNaN(document.mylist.length) ) {}
typeof的运算数未定义,返回的就是 "undefined".
运算数为数字 typeof(x) = "number"
字符串 typeof(x) = "string"
布尔值 typeof(x) = "boolean"
对象,数组和null typeof(x) = "object"
<html>
<head>
<title>运算符typeof的功能和用法演示</title>
</head>
<body>
<p>
<Script Language = "JavaScript">
<!--
document.write("88的数据类型是:"+ typeof(88),"<br>");
document.write("古国的数据类型是:"+ typeof('古国'),"<br>");
document.write("true的数据类型是:"+ typeof(true),"<br>");
document.write("false的数据类型是:"+ typeof(false),"<br>");
// -->
</Script>
<br><br>
另外:<br>
对象类型返回的值为boject<br>
函数类型返回的值是:function<br>
如果没有定义一个变量typeof对这个变量的操作结果是undefined<br>
</body></html>