# How to count the number of objects in an array

**URL:** <https://discourse.nodered.org/t/how-to-count-the-number-of-objects-in-an-array/17186>\
**Category:** General\
**Created:** [27 October 2019 07:03 UTC](https://discourse.nodered.org/t/how-to-count-the-number-of-objects-in-an-array/17186 "2019-10-27T07:03:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gv\_gv](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@gv\_gv](https://discourse.nodered.org/u/gv_gv)\
**Post date:** [27 October 2019 07:03 UTC](https://discourse.nodered.org/t/how-to-count-the-number-of-objects-in-an-array/17186/1 "2019-10-27T07:03:01Z")

</div>

Hello there,

I am using google computer vision pallete for image recognition. It outputs an array at msg.details.faceAnnotations depending upon the number of person in the picture. The objects in the array is equal to the number of person in the image.  
Is there a way i can count the number of objects in the array because that will give me the count of the person in my image.  
This is my code:

```auto
[{"id":"15396718.b8e8a9","type":"debug","z":"9b29502e.1d316","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"details.faceAnnotations","targetType":"msg","x":520,"y":660,"wires":[]},{"id":"d22dd99e.e963c8","type":"cloud-vision-api","z":"9b29502e.1d316","method":"annotate","annotate_body":"","annotate_bodyType":"str","annotate_type":"FACE_DETECTION","annotate_typeType":"str","annotate_keyType":"str","name":"photo","x":430,"y":560,"wires":[["15396718.b8e8a9"]]},{"id":"68dab558.2d454c","type":"file in","z":"9b29502e.1d316","name":"photo","filename":"F:\\Laptop old Windows\\@ img\\bHUPINDER\\IMG-20150208-WA0056.jpg","format":"","chunk":false,"sendError":false,"encoding":"none","x":250,"y":560,"wires":[["d22dd99e.e963c8"]]},{"id":"a6c76d6c.33764","type":"inject","z":"9b29502e.1d316","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":560,"wires":[["68dab558.2d454c"]]}]

```

the output i get is:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/79d8119369f63eed13eb5ddffdd4d804cd16e416.png)

Cheers!!

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 October 2019 07:29 UTC](https://discourse.nodered.org/t/how-to-count-the-number-of-objects-in-an-array/17186/2 "2019-10-27T07:29:34Z")

</div>

Count of elements in array -\> `yourarray.length`

---

<div class="post-metadata">

**Author:** ![gv\_gv](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@gv\_gv](https://discourse.nodered.org/u/gv_gv)\
**Post date:** [27 October 2019 07:48 UTC](https://discourse.nodered.org/t/how-to-count-the-number-of-objects-in-an-array/17186/3 "2019-10-27T07:48:37Z")

</div>

Oh it was this simple. It worked.  
Thanks a lot for helping.

Cheers!!
