使用js的typeof

var isError = typeof 1 == 'number' && '10000';
alert(isError);
// typeof 用来判断当前值的类型

运算数为数字 typeof(x) = "number"

字符串 typeof(x) = "string"

布尔值 typeof(x) = "boolean"

对象,数组和null typeof(x) = "object"

函数 typeof(x) = "function"
posted @ 2011-09-28 09:49  txsun  阅读(141)  评论(0编辑  收藏  举报