Get the count (length) of an object?

I have an object of objects. Example data:

{ ‘285’: {
ShopId: 285, eCommOrderId: 100004, Email: ‘GUESTACCOUNT13@GUESTACCOUNT.COM’, Name: ‘Tim Jones’, Phone: ‘6178038203’, Status: ‘Awaiting Payment’, OrderDate: 2022-04-22T15:16:07.000Z, ItemCount: 1, SubTotal: 12 }
,‘301’: { ShopId: 301, eCommOrderId: 100004, Email: ‘GUESTACCOUNT13@GUESTACCOUNT.COM’, Name: ‘Tim Jones’, Phone: ‘6178203’, Status: ‘Awaiting Payment’, OrderDate: 2022-04-22T15:16:07.000Z, ItemCount: 4, SubTotal: 78 }
}

I would think the count/length of this object is 2, but if I try this -

image

This is what shows up in the log -

What am I missing?

Hi @Tim_Jones

Actually, an object doesn’t have a length because this is not a List.
I assume you want to count the keys of the object and for that just use the following construction

UI Builder - Backendless 2022-06-27 16-31-34

Regards, Vlad

Thanks for the solution, @vladimir-upirov!

Would you mind explaining the difference between lists and objects? I thought they were both basically arrays and objects had keys and lists were without keys.

Tim

Lists:

Objects:

1 Like

Thanks @mark-piller for the videos. I was getting tripped up thinking of objects as associative arrays and then not understanding why if everything is an array it doesn’t work the same.

In addition to watching your videos, I did some reading on JS arrays/objects and it makes more sense now.

Tim