1 判断是否为数组类型 复制代码 代码如下: <BR>//<![CDATA[ <BR>var a=[0]; <BR>document.write(isArray(a),'<br/>'); <BR>function isArray(obj){ <BR>return (typeof obj=='object')&&obj.constructor==Array; <BR>} <BR>//]]> <BR> 2 判断是否为字符串类型 复制代码 代码如下: <BR>//<![CDATA[ <BR>document.write(isString('test'),'<br/>'); <BR>document.write(isString(10),'<br/>'); <BR>function isString(str){ <BR>return (typeof str=='string')&&str.constructor==String; <BR>} <BR>//]]> <BR> 3 判断是否为数值类型 复制代码 代码如下: <BR>//<![CDATA[ <BR>document.write(isNumber('test'),'<br/>'); <BR>document.write(isNumber(10),'<br/>'); <BR>function isNumber(obj){ <BR>return (typeof obj=='number')&&obj.constructor==Number; <BR>} <BR>//]]> <BR> 4 判断是否为日期类型 复制代码 代码如下: <BR>//<![CDATA[ <BR>document.write(isDate(new Date()),'<br/>'); <BR>document.write(isDate(10),'<br/>'); <BR>function isDate(obj){ <BR>return (typeof obj=='object')&&obj.constructor==Date; <BR>} <BR>//]]> <BR> 5 判断是否为函数 复制代码 代码如下: <BR>//<![CDATA[ <BR>document.write(isFunction(function test(){}),'<br/>'); <BR>document.write(isFunction(10),'<br/>'); <BR>function isFunction(obj){ <BR>return (typeof obj=='function')&&obj.constructor==Function; <BR>} <BR>//]]> <BR> 6 判断是否为对象 复制代码 代码如下: <BR>linenum<BR>//<![CDATA[ <BR>document.write(isObject(new Object()),'<br/>'); <BR>document.write(isObject(10),'<br/>'); <BR>function isObject(obj){ <BR>return (typeof obj=='object')&&obj.constructor==Object; <BR>} <BR>//]]> <BR>