Array Basics
Creating and using arrays.
Examples
Creating an Array
Using an array literal to create an array.
const cars = ["Saab", "Volvo", "BMW"];
console.log(cars);Array with different types
Arrays can hold values of different types.
const myArray = [
"Hello",
42,
true,
{ name: "John" },
function() { alert("Hi"); }
];
console.log(myArray[0]); // Hello
console.log(myArray[3].name); // JohnTest Your Knowledge
JavaScript Quiz
No quiz available for this topic yet.