js to get the actual length of objects, arrays, and actual number of elements
/*Get the length of the object, array, and number of elements*@param obj To calculate the length, the element can be 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; }The above article js to obtain the actual length of objects, arrays and actual number of elements is all the content I have shared with you. I hope you can give you a reference and I hope you can support Wulin.com more.