Back to Kids Home
🎁 Lesson 10

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

Name: "Buddy"
Age: 3
Breed: "Golden Retriever"
Is Friendly: true

✏️ 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
}
{ }
Curly Braces

Hold everything together

🏷️
Property Names

Labels like "name" or "age"

📝
Values

The actual information

🔍 Getting Information from Objects

To get one piece of information, use a dot . followed by the property name!

dog.name
➡️
"Buddy"
dog.age
➡️
3
dog.breed
➡️
"Golden Retriever"

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

name: "SuperKid"
health: 100
power: "flying"
level: 5
👾

Monster Enemy

name: "Goblin"
health: 30
damage: 10
isDefeated: false

🔄 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?

let me = {
name: "___",
age: ___,
favoriteColor: "___",
favoriteGame: "___",
hasPets: ___
}

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!