Working with Arrays
Sveip for å vise menyen
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.
123const numbers = [1, 2, 3]; console.log(numbers[0])
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:
123456const users = [ { name: "John", age: 25 }, { name: "Jess", age: 30 } ]; console.log(users[0].age);
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 7
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Seksjon 1. Kapittel 7