Count the length of nested objects using vanilla js
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Count the length of nested objects using vanilla js. As an example, the below would result in 3.

{
"0": {
"mimeType": "image/jpeg",
"fileName": "10.jpg",
"fileExtension": "jpg"
},
"1": {
"mimeType": "image/jpeg",
"fileName": "11.jpg",
"fileExtension": "jpg"
},
"2": {
"mimeType": "image/jpeg",
"fileName": "13.jpg",
"fileExtension": "jpg"
}
};

26 days ago

Crowdsource coding tasks.

1 Solution


Juste use

var size = Object.keys(myObj).length;

Where myObj is your object