您的位置:首页 > Web前端 > JQuery

jquery isType() 类型判断代码

2018-10-12 14:03 676 查看

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 );
},
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: