Created
April 10, 2021 14:33
-
-
Save salmanx/3cebea2f675e73b587e3073d1a58c9a6 to your computer and use it in GitHub Desktop.
.map() also has a substitute that we can use which is .from()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cars = [ | |
{ | |
"color": "purple", | |
"type": "minivan", | |
"registration": new Date('2017-01-03'), | |
"capacity": 7 | |
}, | |
{ | |
"color": "red", | |
"type": "station wagon", | |
"registration": new Date('2018-03-03'), | |
"capacity": 5 | |
} | |
] | |
// map: | |
cars.map(c => c.color) | |
(2) ["purple", "red"] | |
// Array.from() // | |
Array.from(cars, ({color}) => color) | |
(2) ["purple", "red"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment