Monday 8 May 2017

NodeJS number of objects in an array

If I have something like this in JSON and I would like to get number of objects in an array how would I do it? I've tried using .length but it doesn't works.

[
    { name: 'Alex', age: '15'},
    { name: 'Ben', age: '20'},
    { name: 'John', age: '43'}
]

I've done this one let's says this JSON array is called 'names' I tried to count number of objects in an array names.length but it doesn't work.



via thunpisit

No comments:

Post a Comment