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

bookWorking with Arrays

Pyyhkäise näyttääksesi valikon

Arrays are used to store multiple values in a single variable.

const numbers = [1, 2, 3];

Each value in an array has a position called an index. Indexes start from 0.

123
const numbers = [1, 2, 3]; console.log(numbers[0])
copy

Arrays often store collections of similar data, but they can also store objects.

const users = [
  { name: "John", age: 25 },
  { name: "Jess", age: 30 }
];

You can access elements by index and work with their data:

123456
const users = [ { name: "John", age: 25 }, { name: "Jess", age: 30 } ]; console.log(users[0].age);
copy
question mark

What will this code output?

Valitse oikea vastaus

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 7

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

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

Osio 1. Luku 7
some-alt