Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте What Are Objects? | Understanding and Working with Objects
Objects and Prototypes in JavaScript

bookWhat Are Objects?

In JavaScript, an object is a collection of key-value pairs, where each key (also called a property name) is associated with a value. Objects allow you to group related data and functionality together, making your code more organized and flexible. Objects are central to JavaScript, as almost everything in the language—arrays, functions, and even other objects—can be treated as objects. By using objects, you can represent real-world entities, store structured information, and define behaviors using methods.

1234567
const user = { name: "Alice", age: 30, isMember: true }; console.log(JSON.stringify(user));
copy

You can access the properties of an object using either dot notation or bracket notation. With dot notation, you write the object name, a dot, and the property name, like user.name. Bracket notation lets you use a string inside square brackets, such as user["age"]. Both notations allow you to read or update property values. For example, using the user object above, you can get the name with user.name or user["name"], and the age with user.age or user["age"]. Dot notation is typically preferred for property names that are valid identifiers, while bracket notation is useful when the property name is stored in a variable or contains characters not allowed in identifiers.

123456789101112131415
const user = { name: "Alice", age: 30, isMember: true }; // Accessing properties console.log(user.name); // Dot notation console.log(user["age"]); // Bracket notation // Updating properties user.isMember = false; // Dot notation user["name"] = "Bob"; // Bracket notation console.log(JSON.stringify(user));
copy
question mark

Which statement about JavaScript objects and their properties is accurate?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 1

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Can you explain the difference between dot notation and bracket notation in more detail?

How do I add or remove properties from a JavaScript object?

What happens if I try to access a property that doesn't exist on the object?

Awesome!

Completion rate improved to 7.69

bookWhat Are Objects?

Свайпніть щоб показати меню

In JavaScript, an object is a collection of key-value pairs, where each key (also called a property name) is associated with a value. Objects allow you to group related data and functionality together, making your code more organized and flexible. Objects are central to JavaScript, as almost everything in the language—arrays, functions, and even other objects—can be treated as objects. By using objects, you can represent real-world entities, store structured information, and define behaviors using methods.

1234567
const user = { name: "Alice", age: 30, isMember: true }; console.log(JSON.stringify(user));
copy

You can access the properties of an object using either dot notation or bracket notation. With dot notation, you write the object name, a dot, and the property name, like user.name. Bracket notation lets you use a string inside square brackets, such as user["age"]. Both notations allow you to read or update property values. For example, using the user object above, you can get the name with user.name or user["name"], and the age with user.age or user["age"]. Dot notation is typically preferred for property names that are valid identifiers, while bracket notation is useful when the property name is stored in a variable or contains characters not allowed in identifiers.

123456789101112131415
const user = { name: "Alice", age: 30, isMember: true }; // Accessing properties console.log(user.name); // Dot notation console.log(user["age"]); // Bracket notation // Updating properties user.isMember = false; // Dot notation user["name"] = "Bob"; // Bracket notation console.log(JSON.stringify(user));
copy
question mark

Which statement about JavaScript objects and their properties is accurate?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 1
some-alt