Objects are key value pairs of unordered data. Objects can have functions and methods which can be referred using dot or bracket notation. You can access objects using their properties.
Here are some of the characteristics of objects in JS
- Objects can be iterated using “for-in” loop.
- Keys must be unique.
- Values need not be unique.
- Multiple properties can have the same value in an object.
Objects operations & Big O
- Searching by value — O(n)
- To add, delete and accessing — O(1)
Set is a keyed collection of data. Since there are lists, they do not have indices like arrays. When you want to extract unique collection, then a Set can be used. Some of the characteristics of sets are
- They are dynamic in size.
- Insertion order is not preserved.
- Deleting and find in Set is super fast!
- Use when order does not matter for you.
Set operations & Big O
- add( ), delete( ) and has( ) in Set data structure has a time complexity of O(1).
Maps are similar to sets which contains ordered data. Here are the properties of maps
- Maps can be anything including array or an object itself.
- Maps are used only for specific use cases especially retrieving and deleting data.
- Can be Iterated using “for-of” loop.
In built methods
These are the common methods that is used with maps — has( ), get( ) and set( )