In which case we have to go for object in javascript? In which case we have to go for Array in javascript?
-
Possible duplicate of stackoverflow.com/questions/4441139/…?Zee– Zee2015-05-13 07:09:11 +00:00Commented 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.elclanrs– elclanrs2015-05-13 07:09:15 +00:00Commented May 13, 2015 at 7:09
-
possible duplicate of What is the difference between an array and an object?Christina– Christina2015-05-13 07:10:18 +00:00Commented 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!wallop– wallop2015-05-13 07:11:03 +00:00Commented May 13, 2015 at 7:11
-
Thank you for everyone who are try to help me..Developer Strange– Developer Strange2015-05-13 07:28:33 +00:00Commented May 13, 2015 at 7:28
Add a comment
|
1 Answer
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