Array of Objects vs Nested Object?

后端 未结 2 971
再見小時候
再見小時候 2020-12-31 09:35

I have a very basic programing question that i hoped you can shed a light on.

I am working a lot of objects right now and i was wondering if it is better to search f

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-31 09:45

    It's a kind of question with no wrong answers. Both cases are good enough. Depends on case. You should think about the semantics. Do you return array of elements (i.e. list of users, etc.) or just object with a lot of properties within? This structure should depend on data, I guess. But keep in mind, that access by property object.property is faster than array[index].

提交回复
热议问题