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

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  6
some-alt