Kirankumar Kirankumar - 4 months ago 5x
Javascript Question

Count length of array of array using javascript

I have this array and I want to count total numbers into this, can anyone please let me know how can i achieve this using pure javascript

var total = {


You could use Object.keys(total.numbers).length. The first part returns an array with the keys and the second gets the length of it.

var total = { "numbers": { "1": "9897877884", "2": "9867543234", "3": "7898879900", "4": "1234567890" } };


The Object.keys() method returns an array of a given object's own enumerable properties, in the same order as that provided by a loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).


The length property represents an unsigned, 32-bit integer that is always numerically greater than the highest index in the array.