码迷,mamicode.com
首页 > Web开发 > 详细

js判断是对象还是集合

时间:2016-06-11 11:51:05      阅读:434      评论:0      收藏:0      [点我收藏+]

标签:

/*============================================
函数功能:对返回数据中的列表数据进行非空处理
=============================================*/
function formatResponseData(response, str)
{
    // 判断入参是对象还是集合, 然后不同的处理
    var cxlb = response.toString() == "[object Object]" ?  response.cxlb : toString.apply(response) == "[object Array]" ? response : [];
    str = str == undefined ? "--" : str;

    for(var i = 0 , len = cxlb.length; i < len; i++)
    {
        for(var j = 0, len2 = cxlb[i].length; j < len2; j++)
        {
            cxlb[i][j] = cxlb[i][j] == undefined || cxlb[i][j] == null || cxlb[i][j].trim() == "" ? str : cxlb[i][j];
        }
    }
}

 

js判断是对象还是集合

标签:

原文地址:http://www.cnblogs.com/yaowen/p/5574923.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!