Context: The data structure provided below makes it easy to access individual items and their properties. For instance, retrieving the value Volkswagon is a simple task.
let car = {};
let truck = {};
car.one = 'Volkswagon';
car.two = 'Toyota';
truck.one = 'Dakota';
truck.two = 'Tacoma';
let vehicleArray = [car, truck];
console.log(vehicleArray[0].one); //Volkswagon
Inquiry: Is there a way to access the names of the objects stored in the array? Specifically, how can we retrieve the values car and truck from the array itself? I am unsure of how to achieve this without any guidance.
The snippet of code below only displays the properties and values within the object, but not the actual name of the object.
console.log(vehicleArray[0]); // { one: 'Volkswagon', two: 'Toyota' }