Object
In one line
An object is a collection of key-value pairs that groups related data and functions under a single name.
In simple words
A JavaScript object is a container for named values. Each value is stored under a key (a string or symbol), and you access it with dot notation (user.name) or bracket notation (user["name"]). Objects are the primary way to structure data in JavaScript.
Objects can hold any mix of values: strings, numbers, arrays, even other objects and functions. When a function is stored as an object property, it is called a method. This is how objects model real-world entities — a user object might have name, age, and greet() properties.
You create objects with the literal syntax {} or with new Object(). Modern JavaScript adds features like computed property names, shorthand methods, and destructuring, all of which make working with objects more concise.
Example
const user = {
name: "Ada",
age: 36,
skills: ["math", "programming"],
greet() {
return "Hi, I'm " + this.name;
},
};
console.log(user.name); // "Ada"
console.log(user.greet()); // "Hi, I'm Ada"user is an object with primitive values, an array, and a method. Access properties with dot notation.
Related terms
Related Resources
Related Lessons
- Objects
Learn objects, properties, and methods
Related Projects
- Simple Todo List
Model todo items as objects
Related Tools
- JSON Formatter
Format JSON, which is based on JS object syntax
Learn the fundamentals
Deepen your understanding with structured lessons on this topic.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.