jquery isType() 类型判断代码

 更新时间:2011年02月14日 19:10:21   作者:  
jquery isType() 类型判断代码,需要的朋友可以参考下。
复制代码 代码如下:

class2type = {};
toString = Object.prototype.toString;
type: function( obj ) {
return obj == null ?
String( obj ) :
class2type[ toString.call(obj) ] || "object";
},

isFunction: function( obj ) {
return jQuery.type(obj) === "function";
},

isArray: Array.isArray || function( obj ) {
return jQuery.type(obj) === "array";
},

// A crude way of determining if an object is a window
isWindow: function( obj ) {
return obj && typeof obj === "object" && "setInterval" in obj;
},

isNaN: function( obj ) {
return obj == null || !rdigit.test( obj ) || isNaN( obj );
},

相关文章

最新评论