The Big-O of Objects and Arrays

let dog = {
firstName: "Cocoa",
breed: "Golden Retriever",
age: 7,
vaccinated: true
}
dog.owner = "Grace"
=> "Grace"
dig
=> {firstName: "Cocoa", breed: "Golden Retriever", age: 7, vaccinated: true, owner: "Grace"}
delete dog['owner']
=> true
dog
=> {firstName: "Cocoa", breed: "Golden Retriever", age: 7, vaccinated: true}
dog["firstName"]
=> Cocoa
Object.keys(dog)
=> (4) ["firstName", "breed", "age", "vaccinated"]
Object.values(dog)
=> (4) ["Cocoa", "Golden Retriever", 7, true]
Object.entries(dog)
=> (4) [Array(2), Array(2), Array(2), Array(2)]
0: (2) ["firstName", "Cocoa"]
1: (2) ["breed", "Golden Retriever"]
2: (2) ["age", 7]
3: (2) ["vaccinated", true]
length: 4
dog.hasOwnProperty("firstName")
=> true
let students = ["Grace", "Emily", "Carla"]
//index 0. 1. 2.
//adding and removing a student at the end of an array is simplestudents.push("Juan") => add to end of array
students.pop("Juan") => remove at end of array
let students = ["Grace", "Emily", "Carla", "Juan"]
//index 0. 1. 2. 3.
let students = ["Grace", "Emily", "Carla"]
//adding and removing a student at the beginning of an array requires reindexstudents.unshift("Juan") => add at beginning of array
students.shift("Juan") => delete at beginning of array
let students = ["Juan", "Grace", "Emily", "Carla"]
//index 0. 1. 2. 3.
let students = ["Grace", "Emily", "Carla"]

--

--

--

Fullstack Software Engineer | Musician | Food Lover | Coffee Addict

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

bootstrap-vue b-table REST API integration with filters, pagination, sorting and browser history…

Files and Streams-Node.js essential knowledge 4

A Modern MEAN-stack with Angular and Typescript (Part 1)

Javascript in 10 minutes

Understanding and organizing dependencies in node packages

Rails to React Migration: Backwards Compatibility. Part 1

Avoid unnecessary function indirection

How to organize a Chrome extension project

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Grace Yuiko Nakano

Grace Yuiko Nakano

Fullstack Software Engineer | Musician | Food Lover | Coffee Addict

More from Medium

Why are Logarithms used in Time Complexity?

Boring Twenty-Five

IN MY SUMMARY...

Valid Palindromes