首页 > 编程 > JavaScript > 正文

jquery isType() 类型判断代码

2019-11-20 23:56:38
字体:
来源:转载
供稿:网友
复制代码 代码如下:

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 );
},
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表