In JavaScript, properties and methods are fundamental concepts used to interact with objects.
What are Properties?
Properties are values associated with an object. They describe the characteristics or attributes of that object.
| Object | Property | Value |
|---|---|---|
| car | color | "red" |
| car | year | 2020 |
What are Methods?
Methods are functions stored as object properties. They define actions that can be performed on or by the object.
| Object | Method | Action |
|---|---|---|
| car | start() | Starts the engine |
| car | stop() | Stops the engine |

💡 Accessing Properties & Methods
Use dot notation: object.property or object.method().
📌 Deep Dive: Using Properties and Methods
const person = {
name: "Alice",
age: 25,
greet: function() {
return "Hello, my name is " + this.name;
}
};
// Accessing a property
console.log(person.name); // Alice
// Calling a method
console.log(person.greet()); // Hello, my name is Alice
Hello, my name is Alice
Properties vs Methods
Both belong to objects but serve different purposes:
- Properties store data or state.
- Methods perform actions or computations.
⚠️ Remember
Methods need parentheses () when called, while properties do not.
Common Built-in Methods
Many JavaScript objects have built-in methods. For example, strings have methods:
| Method | Description |
|---|---|
| toUpperCase() | Converts string to uppercase |
| slice(start, end) | Extracts part of the string |
| includes(substring) | Checks if substring exists |
📌 Deep Dive: Using a String Method
let message = "hello world";
console.log(message.toUpperCase()); // HELLO WORLD
console.log(message.includes("world")); // true
true
💡 Summary
- Use properties to access or store data within an object.
- Use methods to perform actions, often manipulating properties or returning values.
- Most JavaScript objects come with many useful built-in methods.
Quick Knowledge Check
Test what you just learned
Question 1 of 2
What is the correct way to call a method named run from an object dog?
Question 2 of 2
Which of the following is a property of the object book?
Loading results...