JavaScript Arrays
<!DOCTYPE html> <html> <body> <h2>Creating and reading arrays</h2> <script> // The array literal is the most common way to create an array const fruits = ["apple", "banana", "cherry"]; // Access elements by their zero-based index console.log(fruits[0]); // "apple" console.log(fruits[2]); // "cherry" // length tells you how many elements the array holds console.log(fruits.length); // 3 // The last element is always at index length - 1 console.log(fruits[fruits.length - 1]); // "cherry" </script> </body> </html>