Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Working with Objects | Section
JavaScript Essentials for Backend

Working with Objects

Pyyhkäise näyttääksesi valikon

Objects are used to store related data together.

Instead of using separate variables, you group information into a single structure.

const user = {
  name: "John",
  age: 25,
  isAdmin: false
};

Each value inside an object is stored as a key-value pair.

You can access data using the key:

1234567
const user = { name: "John", age: 25, isAdmin: false }; console.log(user.name);

You can also update values:

123456789
const user = { name: "John", age: 25, isAdmin: false }; user.name = "Peter" console.log(user.name);

And add new ones:

123456789
const user = { name: "John", age: 25, isAdmin: false }; user.email = "john@example.com"; console.log(JSON.stringify(user));

Objects are widely used in backend development because they represent real data, such as users, products, or orders.

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 6

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Osio 1. Luku 6
some-alt