Objects: Things With Details! 📋✨
Objects let you describe something with ALL its details - like a character card that tells you everything about a hero!
🤔 What is an Object?
An object is like a ID card or character profile. It groups together information that all belongs to one thing!
🪪 Dog ID Card
✏️ Writing an Object in Code
In code, we write objects with curly braces {} and list all the details inside!
let dog = { name: "Buddy", age: 3, breed: "Golden Retriever", isFriendly: true } Hold everything together
Labels like "name" or "age"
The actual information
🔍 Getting Information from Objects
To get one piece of information, use a dot . followed by the property name!
dog.name dog.age dog.breed Think of it like: "Hey dog, what's your name?" → "Buddy!"
🎮 Video Game Characters are Objects!
Every character in a video game is an object with properties!
Hero Character
Monster Enemy
🔄 Changing Object Properties
You can change any property of an object! Just like how your game character's health changes when you get hit.
hero.health = 100 Full health!
hero.health = 75 Got hit!
hero.health = 100 Healed up!
🌍 Objects Are Everywhere!
Everything around you could be described as an object with properties!
Your Phone
brand: "Apple"
color: "blue"
battery: 85
A Pizza
size: "large"
topping: "pepperoni"
slices: 8
A Book
title: "Harry Potter"
pages: 309
isRead: true
🧠 Create Your Own!
If YOU were an object, what would your properties be?
⭐ Remember This!
- 1
Objects group together related information
- 2
Objects have properties (like name, age, color)
- 3
Use a dot (.) to access properties:
dog.name - 4
You can change property values anytime!