Advertisement
728x90
You can map the array values without using the map method by just using the from method of Array. Let's map city names from Countries array,
javascript
1const countries = [
2 { name: "India", capital: "Delhi" },
3 { name: "US", capital: "Washington" },
4 { name: "Russia", capital: "Moscow" },
5 { name: "Singapore", capital: "Singapore" },
6 { name: "China", capital: "Beijing" },
7 { name: "France", capital: "Paris" },
8 ];
9
10const cityNames = Array.from(countries, ({ capital }) => capital);
11
12console.log(cityNames); // ['Delhi, 'Washington', 'Moscow', 'Singapore', 'Beijing', 'Paris']Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 23
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
366of476