Arrays with Javascript | Short and Simple | Useful
1 min readMay 2, 2020
Arrays
- Arrays are a continuous block of memory(Sequential).
Operation/Time Complexity:
- Push: O(1)
- Pop: O(1)
- Traverse: O(n)
- Insert: O(n)
Types of Arrays:
- Static Arrays:
- Fixed-size
- Memory is allocated at compile time → Assigned to Stack
- Effective if required size of memory is known earlier
- First in Last Out
- Size must be known at compile time
2. Dynamic Arrays:
- Dynamic Size
- Memory is allocated at run time → Assigned to heap
- Best if unaware of required memory space
- No particular order of assignment
- Size doesn’t require to be known at compile time
How to implement Array with JavaScript