function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Inbox OutboxInbox Outbox 

LWC javascript: array vs object

Sometime you use an array and sometimes an object, how do we know that? How do we know what to use? I am presuming that when we have key value pairs we use object and other times we use array. But there is more to this than what I know.

Please advise. 
 
Best Answer chosen by Inbox Outbox
ANUTEJANUTEJ (Salesforce Developers) 
Hi there,

>> https://blog.salesforcecasts.com/send-arrays-from-lwc-to-apex-methods/

>> https://www.salesforcepoint.com/2020/07/Lwc-Iteration-Array-List-Items.html

>> https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.data_wire_service_about

The above links have details that can help you, can you try checking once.

Let me know if it helps you and close your query by marking it as the best answer so that it can help others in the future.  

Thanks.

All Answers

PriyaPriya (Salesforce Developers) 

Hi 

Kindly refer this below article to understand their use in detail :- 

https://www.sfdcblogs.com/post/useful-javascript-s-methods-in-lwc-and-lightning-component-part-i

If the above information helps, please mark it as best answer.

Regards,

Priya Ranjan

Inbox OutboxInbox Outbox
Thank you Priya for answering me. That link covers array. I want to under why we sometimes we use object and sometimes we use an array?
ANUTEJANUTEJ (Salesforce Developers) 
Hi there,

>> https://blog.salesforcecasts.com/send-arrays-from-lwc-to-apex-methods/

>> https://www.salesforcepoint.com/2020/07/Lwc-Iteration-Array-List-Items.html

>> https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.data_wire_service_about

The above links have details that can help you, can you try checking once.

Let me know if it helps you and close your query by marking it as the best answer so that it can help others in the future.  

Thanks.
This was selected as the best answer
Inbox OutboxInbox Outbox
Anutej, 
Thank you for the links. 
What I understand is that when we have a list we use an array and we have key value pairs we use an object? Am I right?