yansj1997
    /*获取对象、数组的长度、元素个数
     *@param obj 要计算长度的元素,可以为object、array、string
    */
    function count(obj){
        var objType = typeof obj;
        if(objType == "string"){
            return obj.length;
        }else if(objType == "object"){
            var objLen = 0;
            for(var i in obj){
                objLen++;
            }
            return objLen;
        }
        return false;
    }

js获取对象、数组的实际长度,即元素实际个数。

分类:

技术点:

相关文章:

  • 2021-12-18
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
  • 2021-12-29
  • 2021-07-11
  • 2021-12-20
  • 2021-10-01
猜你喜欢
  • 2021-11-26
  • 2022-12-23
  • 2022-01-06
  • 2021-07-21
  • 2021-12-31
  • 2022-01-02
  • 2022-12-23
相关资源
相似解决方案