Through the lens of Big O
Let's spend a couple minutes analyzing the things we do all the time in JS: working with Arrays, Objects, and built-in methods.
let instructor = {
firstName: "Kelly",
isInstructor: true,
favoriteNumbers: [1,2,3,4]
}
Unordered, key value pairs!
Insertion - O(1)
Removal - O(1)
Searching - O(N)
Access - O(1)
When you don't need any ordering, objects are an excellent choice!
Object.keys - O(N)
Object.values - O(N)
Object.entries - O(N)
hasOwnProperty - O(1)
let names = ["Michael", "Melissa", "Andrea"];
let values = [true, {}, [], 2, "awesome"];
Ordered lists!
Insertion - It depends....
Removal - It depends....
Searching - O(N)
Access - O(1)
Let's see what we mean by that!
You don't need to know all this...
😵
Inserting at the beginning is not as easy as we might think! There are more efficient data structures for that!