Quick Review: Objects
Part of the Object Oriented Programming section of Coddy's JavaScript journey — lesson 1 of 56.
From Data Objects to Smart Objects
In Section 2 Logic and Flow, you learned how to use objects as data containers. Now, we'll transform these static data objects into dynamic, intelligent objects that can perform actions and manage their own state.
What You Already Know from Section 2:
Objects are collections of key-value pairs that let you store related data together. Think of them like containers that hold information about something.
// Object as a simple data container
const player = {
name: "Alex",
health: 100,
level: 2,
inventory: ["sword", "potion"]
};
// Accessing data
console.log(player.name); // "Alex"
console.log(player.health); // 100
console.log(player.inventory[0]); // "sword" - access array element
// Updating data
player.health = 85;Challenge
Print the player's level in the console.
Cheat sheet
Objects can store related data as key-value pairs and be accessed using dot notation:
const player = {
name: "Alex",
health: 100,
level: 2,
inventory: ["sword", "potion"]
};
// Accessing object properties
console.log(player.name); // "Alex"
console.log(player.health); // 100
console.log(player.inventory[0]); // "sword"
// Updating object properties
player.health = 85;Try it yourself
const player = {
name: "Alex",
health: 100,
level: 2,
inventory: ["sword", "potion"]
};
// TODO: print the player's level in the consoleThis lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Object Oriented Programming
1Objects & The this Keyword
Quick Review: ObjectsAdding Methods to ObjectsUnderstanding the this KeywordConstructor FunctionsThe new KeywordRecap Challenge7 Inheritance & The extends Key
InheritanceThe "is-a" RelationshipThe extends KeywordThe super() MethodInheriting Properties&MethodsRecap Challenge2Organizing Code
What are Modules?Exporting with exportImporting with importDefault vs. Named Exports8Organizing OOP Code
Organize Classes into Modules11Project: A Shape Renderer
Setup: Shape Class & ExportCircle Class Inheritance9Static Methods & Properties
Class-Level vs. Instance-LevelStatic PropertiesStatic Utility MethodsRecap challenge