龙空技术网

借鉴jquery实现对js中数据类型的判断

webxmsj 340

前言:

此时大家对“jquery获得表格行数据类型”都比较珍视,兄弟们都需要分析一些“jquery获得表格行数据类型”的相关文章。那么小编在网摘上收集了一些对于“jquery获得表格行数据类型””的相关内容,希望兄弟们能喜欢,你们一起来学习一下吧!

js学习

var class2type = {};

// 生成class2type映射

"Boolean Number String Function Array Date RegExp Object Error".split(" ").map(function(item, index) {

class2type["[object " + item + "]"] = item.toLowerCase();

})

function type(obj) {

if (obj == null) {

return obj + "";

}

return typeof obj === "object" || typeof obj === "function" ?

class2type[Object.prototype.toString.call(obj)] || "object" :

typeof obj;

}

标签: #jquery获得表格行数据类型