Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Arrays | Section
JavaScript Essentials for React Native Development

bookArrays

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

Arrays are ordered lists of values, stored in a single variable. You can think of an array as a collection of items, such as a list of fruit names, where each item has a specific position called an index. In JavaScript, array indexes start at 0, so the first element is at index 0, the second at index 1, and so on.

12345678910
// Creating an array const fruits = ["apple", "banana", "cherry"]; // Accessing elements by index console.log(fruits[0]); // "apple" console.log(fruits[2]); // "cherry" // Modifying values fruits[1] = "blueberry"; console.log(fruits); // ["apple", "blueberry", "cherry"]
copy

Accessing a value in an array is done by referencing its index inside square brackets. For example, fruits[0] gives you the first fruit in the array, while fruits[2] gives you the third. You can also change the value at a specific index by assigning a new value to it, like fruits[1] = "blueberry", which replaces the second fruit.

Arrays are commonly used to store lists of related data, such as items in a shopping cart, user names, or scores in a game. Their ability to hold multiple values and let you access or change them by index makes arrays a powerful tool for managing collections in your code.

question mark

Which statement about arrays in JavaScript is true?

Виберіть правильну відповідь

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

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

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

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

Запитати АІ

expand

Запитати АІ

ChatGPT

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

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