JS Tutorial



JS OBJECTS


JavaScript Objects

In JavaScript, an object is a collection of key-value pairs. It’s used to store multiple values in a single variable, like a real-world entity with properties and behaviors.

πŸ”Ή Real Life Analogy: A car object can have properties like brand, model, color and methods like drive(), brake().

πŸ“¦ Creating an Object

let person = {
  name: "John",
  age: 30,
  isStudent: false
};

πŸ” Accessing Object Properties

  • person.name – Dot notation
  • person["age"] – Bracket notation
console.log(person.name);
console.log(person["age"]);

πŸ› οΈ Adding & Updating Properties

person.country = "India";
person.age = 31;

🧹 Deleting Properties

delete person.isStudent;

βš™οΈ Object Methods

You can define functions inside objects:

let user = {
  name: "Alice",
  greet: function() {
    return "Hello, " + this.name;
  }
};
console.log(user.greet());

πŸ§ͺ Try It Yourself

Output will appear here
πŸ“˜ Summary:
JavaScript objects are powerful for structuring data using keys and values. You can store data and behavior together using properties and methods.

🌟 Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review