0

In which case we have to go for object in javascript? In which case we have to go for Array in javascript?

5
  • Possible duplicate of stackoverflow.com/questions/4441139/…? Commented May 13, 2015 at 7:09
  • It is not always one or the other, it can be both, like an array of objects. It depends. Commented May 13, 2015 at 7:09
  • possible duplicate of What is the difference between an array and an object? Commented May 13, 2015 at 7:10
  • An object is a key,value pair and an array is a list of data generally of the same type. If the contents of your data has different aspects to it such as name, address, age then go for object else if it is just a list of age or names then go for array. You can also have an object within an array or an array within an object. It is all dependent on the scenario! Commented May 13, 2015 at 7:11
  • Thank you for everyone who are try to help me.. Commented May 13, 2015 at 7:28

1 Answer 1

0

If you you have collection of properties use object, because using object is straight for you can access the desired property by obj.propName. In case of array you need to remember the index of property. If you have collection of objects use array.
For more detail
When to use an object or an array in javascript

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.