R
R
riddlr2018-10-10 19:16:28
API
riddlr, 2018-10-10 19:16:28

How to return a list of posts / comments, etc. - as an object or an array?

The situation when the API arrives, for example, a list of comments. The vast majority of tutorials do it simply - an array with objects. But I noticed that many real applications return data as an object, where the key is the ID, and the value is the content itself.
What are the advantages of this method? Is it worth doing the same?
APD. It seems that here is the source of this trend - https://firebase.googleblog.com/2014/04/best-pract...
Google believes that arrays are evil.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2018-10-10
@riddlr

It doesn't really matter, it depends on the task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question