


However, depending on the use case, choosing the correct structure contributes to deliver optimal solution - and we want to achieve that. In programming world, taken same data set (no duplicates), we can either use Array or Set to be our chosen structure to store this data set. Keyed collections are collections which use keys these contain elements which are iterable in the order of insertion.Įasy right? Now one may wonder, if they are different, why we bother compare between them? Indexed collections are collections of data which are ordered by an index value In addition, Array is considered as “ indexed collection” type of data structure, while Set is considered as “ keyed collection”.Ī quick reminder for those who don’t remember, One of the biggest differences here, you may notice, is that elements in Array can be duplicate (unless you tell it not to be), and in Set, they just can’t (regardless what you decide). Yup, by definition, Array and Set are technically different concepts. Set, more familiar as a Math concept, is an abstract data type which contains only distinct elements/objects without the need of being allocated orderly by index. Well, in general, Array is type of structure representing block of data (numbers, objects, etc…) allocated in consecutive memory.

Everyone who works with JS until now is familiar with Array ( don’t tell me you don’t).
