javascript各种数据类型判断方法

    xiaoxiao2021-03-25  75

    /*类型判断*/ //写在一起是为了集中给予功能方面的提示 var typeJduge={ Json:function(obj){ return typeof(obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length; }, Array:function(obj){ return Object.prototype.toString.call(obj) === '[object Array]'; }, Obj:function(obj){ return obj && typeof (obj) == 'object' && Object.prototype.toString.call(obj).toLowerCase() == "[object object]"; }, Function:function(obj){ return Object.prototype.toString.call(obj)=="[object Function]"; }, RegExp:function(obj){ return Object.prototype.toString.call(obj)=="[object RegExp]"; }, Integer:function(obj){ return typeof obj === 'number' && obj%1 === 0; } };
    转载请注明原文地址: https://ju.6miu.com/read-40386.html

    最新回复(0)