Objects - Structured Data
Create and use JavaScript objects
Beginner⏱️ 15 minutes
Lesson Content
JavaScript Objects
Objects store related data together.
Creating Objects:
const person = {
name: "John",
age: 30,
city: "New York",
greet: function() {
return "Hello, I'm " + this.name;
}
};
Accessing Properties:
console.log(person.name); // Dot notation
console.log(person["age"]); // Bracket notation
console.log(person.greet()); // Call method
Task: Create a car object with brand, model, year properties and a getInfo method.
javascript
Loading...
Expected Output: Toyota
Next (Complete this lesson first)
DOM Manipulation - Change HTML